-
Notifications
You must be signed in to change notification settings - Fork 0
/
lifedb_schema_generator.ml
105 lines (90 loc) · 2.64 KB
/
lifedb_schema_generator.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
(* Copyright (C) 2009 Anil Madhavapeddy <anil@recoil.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
open Sql_orm.Schema
let lifedb = make [
"attachment" , [
text ~flags:[`Unique; `Index] "file_name";
text "mime_type";
], [ [], ["file_name"] ], default_opts;
"contact" , [
text "file_name";
text ~flags:[`Unique; `Index] "uid";
text ~flags:[`Optional] "first_name";
text ~flags:[`Optional] "last_name";
date "mtime";
], [], default_opts;
"mtype" , [
text ~flags:[`Unique; `Index] "name";
text "label";
text ~flags:[`Optional] "icon";
text "implements";
], [ [],["name"] ], default_opts;
"service" , [
text "name";
text "uid";
foreign ~flags:[`Optional] "contact" "contact";
],[], default_opts;
"tag" , [
text "name"
], [], default_opts;
"entry" , [
text ~flags:[`Unique; `Index] "uid";
text "file_name";
date ~flags:[`Index] "created";
foreign "mtype" "mtype";
foreign "service" "from";
foreign_many "service" "recipients";
foreign_many "attachment" "atts";
foreign_many "tag" "tags";
text ~flags:[`Optional; `Index] "inbox";
integer "delivered";
], [
["uid"],[];
["file_name"],[];
["created"],[];
[],["inbox";"delivered"];
[],["uid"];
[],["file_name"]
], default_opts;
]
let sync = make [
"dircache", [
text "dir";
date "mtime";
],[], default_opts;
]
let log = make [
"task", [
text "name";
date "started";
real "time_taken";
integer "exit_code";
], [], default_opts;
]
let keychain = make [
"passwd", [
text "service";
date "ctime";
text "username";
text "encpasswd";
], [
[], ["service";"username"]
], { unique = [ [ "service"; "username" ] ] }
]
let _ =
Sql_orm.generate ~debug:false lifedb "lifedb_schema";
Sql_orm.generate ~debug:false sync "sync_schema";
Sql_orm.generate ~debug:false log "log_schema";
Sql_orm.generate ~debug:false keychain "keychain_schema";
()