diff options
author | June McEnroe <june@causal.agency> | 2020-02-28 00:06:46 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-02-28 00:13:42 -0500 |
commit | c0fafbc887a147ee77278a5bfd852e171aeb471c (patch) | |
tree | 79e75b6c48f3e8b22a1583a9ddafdb1cb18040bf /database.h | |
parent | Include <>/-/* around nicks in coloring (diff) | |
download | litterbox-c0fafbc887a147ee77278a5bfd852e171aeb471c.tar.gz litterbox-c0fafbc887a147ee77278a5bfd852e171aeb471c.zip |
Implement the causal.agency/consumer capability
Diffstat (limited to '')
-rw-r--r-- | database.h | 30 |
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) { |