aboutsummaryrefslogtreecommitdiff
path: root/sqlinit.txt
diff options
context:
space:
mode:
authorFranklin Wei <me@fwei.tk>2018-06-30 20:01:43 -0400
committerFranklin Wei <me@fwei.tk>2018-06-30 20:01:43 -0400
commitf0519032a59aff4ca9edcb2916e094db93e08942 (patch)
tree2888deb8615fb03f30bab36773a9605a0546160d /sqlinit.txt
parent03a354b8d0f2a8820db9571c639804648d804ac4 (diff)
downloadcsaa-f0519032a59aff4ca9edcb2916e094db93e08942.zip
csaa-f0519032a59aff4ca9edcb2916e094db93e08942.tar.gz
csaa-f0519032a59aff4ca9edcb2916e094db93e08942.tar.bz2
csaa-f0519032a59aff4ca9edcb2916e094db93e08942.tar.xz
Add dummy client/server for comparison; fix bugs and polish database code
Diffstat (limited to 'sqlinit.txt')
-rw-r--r--sqlinit.txt33
1 files changed, 23 insertions, 10 deletions
diff --git a/sqlinit.txt b/sqlinit.txt
index 8f17229..06cd076 100644
--- a/sqlinit.txt
+++ b/sqlinit.txt
@@ -1,4 +1,17 @@
-CREATE TABLE FileRecords (
+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,
@@ -7,7 +20,7 @@ HMAC BLOB,
ACL_logleaves INTEGER
);
-CREATE TABLE FileLeaves (
+CREATE TABLE IF NOT EXISTS FileLeaves (
LeafIdx INTEGER,
Idx INTEGER,
NextIdx INTEGER,
@@ -15,13 +28,13 @@ Val BLOB,
PRIMARY KEY (LeafIdx)
);
-CREATE TABLE FileNodes (
+CREATE TABLE IF NOT EXISTS FileNodes (
NodeIdx INTEGER,
Val BLOB,
PRIMARY KEY (NodeIdx)
);
-CREATE TABLE Versions (
+CREATE TABLE IF NOT EXISTS Versions (
FileIdx INTEGER,
Version INTEGER,
KF BLOB,
@@ -34,7 +47,7 @@ PRIMARY KEY (FileIdx, Version),
FOREIGN KEY (FileIdx) REFERENCES FileRecords(Idx)
);
-CREATE TABLE ACLLeaves (
+CREATE TABLE IF NOT EXISTS ACLLeaves (
FileIdx INTEGER,
LeafIdx INTEGER,
Idx INTEGER,
@@ -44,7 +57,7 @@ PRIMARY KEY (FileIdx, LeafIdx),
FOREIGN KEY (FileIdx) REFERENCES FileRecords(Idx)
);
-CREATE TABLE ACLNodes (
+CREATE TABLE IF NOT EXISTS ACLNodes (
FileIdx INTEGER,
NodeIdx INTEGER,
Val BLOB,
@@ -52,7 +65,7 @@ PRIMARY KEY (FileIdx, NodeIdx),
FOREIGN KEY (FileIdx) REFERENCES FileRecords(Idx)
);
-CREATE TABLE BCLeaves (
+CREATE TABLE IF NOT EXISTS BCLeaves (
FileIdx INTEGER,
Version INTEGER,
LeafIdx INTEGER,
@@ -64,7 +77,7 @@ FOREIGN KEY (FileIdx) REFERENCES FileRecords(Idx),
FOREIGN KEY (Version) REFERENCES Versions(Version)
);
-CREATE TABLE BCNodes (
+CREATE TABLE IF NOT EXISTS BCNodes (
FileIdx INTEGER,
Version INTEGER,
Val BLOB,
@@ -74,7 +87,7 @@ FOREIGN KEY (FileIdx) REFERENCES FileRecords(Idx),
FOREIGN KEY (Version) REFERENCES Versions(Version)
);
-CREATE TABLE CFLeaves (
+CREATE TABLE IF NOT EXISTS CFLeaves (
FileIdx INTEGER,
Version INTEGER,
LeafIdx INTEGER,
@@ -86,7 +99,7 @@ FOREIGN KEY (FileIdx) REFERENCES FileRecords(Idx),
FOREIGN KEY (Version) REFERENCES Versions(Version)
);
-CREATE TABLE CFNodes (
+CREATE TABLE IF NOT EXISTS CFNodes (
FileIdx INTEGER,
Version INTEGER,
Val BLOB,