diff options
author | June McEnroe <june@causal.agency> | 2020-07-11 14:23:51 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-07-11 14:23:51 -0400 |
commit | 6c82c1e785847986d9adda4fc4c3d637f94d37fe (patch) | |
tree | e69bc70a43911122fa7d40875d7d52a7fe7d38be | |
parent | Delay creating eventsTime index when migration from v2 (diff) | |
download | litterbox-1.4p1.tar.gz litterbox-1.4p1.zip |
Replace time index with (context, time) index 1.4p1
This is what it should have been...
-rw-r--r-- | database.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/database.h b/database.h index e2d52ff..46679f5 100644 --- a/database.h +++ b/database.h @@ -42,7 +42,7 @@ #define DATABASE_PATH "litterbox/litterbox.sqlite" -enum { DatabaseVersion = 4 }; +enum { DatabaseVersion = 5 }; #define ENUM_TYPE \ X(Privmsg, "privmsg") \ @@ -282,7 +282,7 @@ static const char *InitSQL = SQL( target TEXT, message TEXT ); - CREATE INDEX eventsTime ON events (time); + CREATE INDEX eventsContextTime ON events (context, time); CREATE VIEW text ( event, network, channel, query, nick, user, target, message @@ -323,7 +323,7 @@ static const char *InitSQL = SQL( UNIQUE (host, port) ); - PRAGMA user_version = 4; + PRAGMA user_version = 5; COMMIT TRANSACTION; ); @@ -370,9 +370,17 @@ static const char *MigrationSQL[] = { UPDATE motds SET time = strftime('%s', time); UPDATE topics SET time = strftime('%s', time); UPDATE events SET time = strftime('%s', time); - CREATE INDEX IF NOT EXISTS eventsTime ON events (time); + // Don't bother creating the index that will be immediately dropped in + // version 5. + // CREATE INDEX IF NOT EXISTS eventsTime ON events (time); PRAGMA user_version = 4; ), + + SQL( + DROP INDEX IF EXISTS eventsTime; + CREATE INDEX eventsContextTime ON events (context, time); + PRAGMA user_version = 5; + ), }; static inline void dbMigrate(void) { |