aboutsummaryrefslogtreecommitdiff
path: root/sqlinit.txt
blob: 72634eaac39188f0a8fc7d01e87e46b3dbac02db (plain)
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
106
107
108
109
110
111
PRAGMA foreign_keys = OFF;

DROP TABLE IF EXISTS FileRecords;
DROP TABLE IF EXISTS FileLeaves;
DROP TABLE IF EXISTS FileNodes;
DROP TABLE IF EXISTS Versions;
DROP TABLE IF EXISTS ACLLeaves;
DROP TABLE IF EXISTS ACLNodes;
DROP TABLE IF EXISTS BCLeaves;
DROP TABLE IF EXISTS BCNodes;
DROP TABLE IF EXISTS CFLeaves;
DROP TABLE IF EXISTS CFNodes;

CREATE TABLE IF NOT EXISTS FileRecords (
Idx INTEGER,
Ver INTEGER,
Ctr INTEGER,
Cert BLOB,
HMAC BLOB,
ACL_logleaves INTEGER,
PRIMARY KEY (Idx)
);

CREATE TABLE IF NOT EXISTS FileLeaves (
LeafIdx INTEGER,
Idx INTEGER,
NextIdx INTEGER,
Val BLOB,
PRIMARY KEY (LeafIdx)
);

CREATE TABLE IF NOT EXISTS FileNodes (
NodeIdx INTEGER,
Val BLOB,
PRIMARY KEY (NodeIdx)
);

CREATE TABLE IF NOT EXISTS Versions (
FileIdx INTEGER,
Version INTEGER,
KF BLOB,
encrypted_secret BLOB,
Cert BLOB,
HMAC BLOB,
Buildcode_logleaves INTEGER,
Composefile_logleaves INTEGER,
PRIMARY KEY (FileIdx, Version),
FOREIGN KEY (FileIdx) REFERENCES FileRecords(Idx)
);

CREATE TABLE IF NOT EXISTS ACLLeaves (
FileIdx INTEGER,
LeafIdx INTEGER,
Idx INTEGER,
NextIdx INTEGER,
Val BLOB,
PRIMARY KEY (FileIdx, LeafIdx),
FOREIGN KEY (FileIdx) REFERENCES FileRecords(Idx)
);

CREATE TABLE IF NOT EXISTS ACLNodes (
FileIdx INTEGER,
NodeIdx INTEGER,
Val BLOB,
PRIMARY KEY (FileIdx, NodeIdx),
FOREIGN KEY (FileIdx) REFERENCES FileRecords(Idx)
);

CREATE TABLE IF NOT EXISTS BCLeaves (
FileIdx INTEGER,
Version INTEGER,
LeafIdx INTEGER,
Idx INTEGER,
NextIdx INTEGER,
Val BLOB,
PRIMARY KEY (FileIdx, Version, LeafIdx),
FOREIGN KEY (FileIdx) REFERENCES FileRecords(Idx),
FOREIGN KEY (Version) REFERENCES Versions(Version)
);

CREATE TABLE IF NOT EXISTS BCNodes (
FileIdx INTEGER,
Version INTEGER,
Val BLOB,
NodeIdx INTEGER,
PRIMARY KEY (FileIdx, Version, NodeIdx),
FOREIGN KEY (FileIdx) REFERENCES FileRecords(Idx),
FOREIGN KEY (Version) REFERENCES Versions(Version)
);

CREATE TABLE IF NOT EXISTS CFLeaves (
FileIdx INTEGER,
Version INTEGER,
LeafIdx INTEGER,
Idx INTEGER,
NextIdx INTEGER,
Val BLOB,
PRIMARY KEY (FileIdx, Version, LeafIdx),
FOREIGN KEY (FileIdx) REFERENCES FileRecords(Idx),
FOREIGN KEY (Version) REFERENCES Versions(Version)
);

CREATE TABLE IF NOT EXISTS CFNodes (
FileIdx INTEGER,
Version INTEGER,
Val BLOB,
NodeIdx INTEGER,
PRIMARY KEY (FileIdx, Version, NodeIdx),
FOREIGN KEY (FileIdx) REFERENCES FileRecords(Idx),
FOREIGN KEY (Version) REFERENCES Versions(Version)
);