summary refs log tree commit diff
path: root/database.h
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-12-06 14:15:57 -0500
committerJune McEnroe <june@causal.agency>2019-12-06 14:15:57 -0500
commiteb0da60e1fb07ef3e1bd71d268125ecfdf1a4803 (patch)
treeb82bbc455d97264ce7b98f39eb182b5c77dd7649 /database.h
parentAdd deduplication function to unscoop (diff)
downloadlitterbox-eb0da60e1fb07ef3e1bd71d268125ecfdf1a4803.tar.gz
litterbox-eb0da60e1fb07ef3e1bd71d268125ecfdf1a4803.zip
Rename IDs to nouns and join with USING
Diffstat (limited to '')
-rw-r--r--database.h22
1 files changed, 11 insertions, 11 deletions
diff --git a/database.h b/database.h
index 2481262..eec6cb6 100644
--- a/database.h
+++ b/database.h
@@ -151,44 +151,44 @@ static inline int dbVersion(sqlite3 *db) {
 static const char *InitSQL = {
 	"BEGIN TRANSACTION;"
 	"CREATE TABLE networks ("
-		"id INTEGER PRIMARY KEY,"
+		"network INTEGER PRIMARY KEY,"
 		"name TEXT NOT NULL UNIQUE"
 	");"
 	"CREATE TABLE contexts ("
-		"id INTEGER PRIMARY KEY,"
-		"networkID INTEGER NOT NULL REFERENCES networks,"
+		"context INTEGER PRIMARY KEY,"
+		"network INTEGER NOT NULL REFERENCES networks,"
 		"name TEXT NOT NULL,"
 		"query BOOLEAN NOT NULL,"
-		"UNIQUE (networkID, name)"
+		"UNIQUE (network, name)"
 	");"
 	"CREATE TABLE names ("
-		"id INTEGER PRIMARY KEY,"
+		"name INTEGER PRIMARY KEY,"
 		"nick TEXT NOT NULL,"
 		"user TEXT NOT NULL,"
 		"host TEXT NOT NULL,"
 		"UNIQUE (nick, user, host)"
 	");"
 	"CREATE TABLE events ("
-		"id INTEGER PRIMARY KEY,"
+		"event INTEGER PRIMARY KEY,"
 		"time DATETIME NOT NULL,"
 		"type INTEGER NOT NULL,"
-		"contextID INTEGER NOT NULL REFERENCES contexts,"
-		"nameID INTEGER NOT NULL REFERENCES names,"
+		"context INTEGER NOT NULL REFERENCES contexts,"
+		"name INTEGER NOT NULL REFERENCES names,"
 		"target TEXT,"
 		"message TEXT"
 	");"
 	"CREATE VIRTUAL TABLE search USING fts5 ("
 		"message,"
 		"content = events,"
-		"content_rowid = id,"
+		"content_rowid = event,"
 		"tokenize = 'porter'"
 	");"
 	"CREATE TRIGGER eventsInsert AFTER INSERT ON events BEGIN"
-	" INSERT INTO search (rowid, message) VALUES (new.id, new.message);"
+	" INSERT INTO search (rowid, message) VALUES (new.event, new.message);"
 	"END;"
 	"CREATE TRIGGER eventsDelete AFTER DELETE ON events BEGIN"
 	" INSERT INTO search (search, rowid, message)"
-	" VALUES ('delete', old.id, old.message);"
+	" VALUES ('delete', old.event, old.message);"
 	"END;"
 	"COMMIT TRANSACTION;"
 };