summary refs log tree commit diff
path: root/database.h
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-28 00:06:46 -0500
committerJune McEnroe <june@causal.agency>2020-02-28 00:13:42 -0500
commitc0fafbc887a147ee77278a5bfd852e171aeb471c (patch)
tree79e75b6c48f3e8b22a1583a9ddafdb1cb18040bf /database.h
parentInclude <>/-/* around nicks in coloring (diff)
downloadlitterbox-c0fafbc887a147ee77278a5bfd852e171aeb471c.tar.gz
litterbox-c0fafbc887a147ee77278a5bfd852e171aeb471c.zip
Implement the causal.agency/consumer capability
Diffstat (limited to '')
-rw-r--r--database.h30
1 files changed, 25 insertions, 5 deletions
diff --git a/database.h b/database.h
index d9b2718..5893f77 100644
--- a/database.h
+++ b/database.h
@@ -31,7 +31,7 @@
 
 #define DATABASE_PATH "litterbox/litterbox.sqlite"
 
-enum { DatabaseVersion = 1 };
+enum { DatabaseVersion = 2 };
 
 #define ENUM_TYPE \
 	X(Privmsg, "privmsg") \
@@ -172,9 +172,10 @@ static inline void dbBindNull(sqlite3_stmt *stmt, const char *param) {
 	errx(EX_SOFTWARE, "sqlite3_bind_null: %s", sqlite3_errmsg(db));
 }
 
-static inline void dbBindInt(sqlite3_stmt *stmt, const char *param, int value) {
-	if (!sqlite3_bind_int(stmt, dbParam(stmt, param), value)) return;
-	errx(EX_SOFTWARE, "sqlite3_bind_int: %s", sqlite3_errmsg(db));
+static inline void
+dbBindInt(sqlite3_stmt *stmt, const char *param, sqlite3_int64 value) {
+	if (!sqlite3_bind_int64(stmt, dbParam(stmt, param), value)) return;
+	errx(EX_SOFTWARE, "sqlite3_bind_int64: %s", sqlite3_errmsg(db));
 }
 
 static inline void dbBindText5(
@@ -301,7 +302,14 @@ static const char *InitSQL = SQL(
 		) SELECT 'delete', * FROM text WHERE event = old.event;
 	END;
 
-	PRAGMA user_version = 1;
+	CREATE TABLE consumers (
+		host STRING NOT NULL,
+		port INTEGER NOT NULL,
+		pos INTEGER NOT NULL,
+		UNIQUE (host, port)
+	);
+
+	PRAGMA user_version = 2;
 
 	COMMIT TRANSACTION;
 );
@@ -328,6 +336,18 @@ static const char *MigrationSQL[] = {
 		PRAGMA user_version = 1;
 		COMMIT TRANSACTION;
 	),
+
+	SQL(
+		BEGIN TRANSACTION;
+		CREATE TABLE consumers (
+			host STRING NOT NULL,
+			port INTEGER NOT NULL,
+			pos INTEGER NOT NULL,
+			UNIQUE (host, port)
+		);
+		PRAGMA user_version = 2;
+		COMMIT TRANSACTION;
+	),
 };
 
 static inline void dbMigrate(void) {
2-18 18:07:25 -0500'>2019-02-18Match Sh and Ss as Tag in mdocJune McEnroe 2019-02-18Match statics and typedefs as TagJune McEnroe 2019-02-18Clean up htmlHeaderJune McEnroe 2019-02-18Remove hi line numberingJune McEnroe 2019-02-18Add Tag class to hiJune McEnroe 2019-02-17Generate HTML with hi -n -f html -o anchorJune McEnroe 2019-02-17Add hi -f html -o anchor for line number linksJune McEnroe 2019-02-17Simplify temp trap in upJune McEnroe 2019-02-17Add line numbers to hiJune McEnroe 2019-02-17Always split spans after newlinesJune McEnroe 2019-02-15Color format specifiers light cyan in vimJune McEnroe 2019-02-15Highlight Interp as yellowJune McEnroe 2019-02-15Highlight strings in sh command substitutionsJune McEnroe 2019-02-15Add nmap gpJune McEnroe 2019-02-14Avoid newline when copying URL to pasteboardJune McEnroe 2019-02-13Add forgotten "sixth" book of H2G2June McEnroe