From 3e7255ff20926abeb523691ccebad6371404febb Mon Sep 17 00:00:00 2001 From: Reto Brunner Date: Thu, 29 Dec 2022 14:35:57 +0100 Subject: [PATCH] sqlite: Add primary keys to the messages table We want primary keys to never get re-used to so that we can implement jump to messages / context fetching etc in the future. This isn't hooked up yet at all to the rest of the code, only the schema is changed --- server/plugins/messageStorage/sqlite.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/plugins/messageStorage/sqlite.ts b/server/plugins/messageStorage/sqlite.ts index 6cee2a8b..349d2ec2 100644 --- a/server/plugins/messageStorage/sqlite.ts +++ b/server/plugins/messageStorage/sqlite.ts @@ -25,12 +25,12 @@ try { type Migration = {version: number; stmts: string[]}; -export const currentSchemaVersion = 1520239200; // use `new Date().getTime()` +export const currentSchemaVersion = 1672236339873; // use `new Date().getTime()` // Desired schema, adapt to the newest version and add migrations to the array below const schema = [ "CREATE TABLE IF NOT EXISTS options (name TEXT, value TEXT, CONSTRAINT name_unique UNIQUE (name))", - "CREATE TABLE IF NOT EXISTS messages (network TEXT, channel TEXT, time INTEGER, type TEXT, msg TEXT)", + "CREATE TABLE IF NOT EXISTS messages (id INTEGER PRIMARY KEY AUTOINCREMENT, network TEXT, channel TEXT, time INTEGER, type TEXT, msg TEXT)", "CREATE INDEX IF NOT EXISTS network_channel ON messages (network, channel)", "CREATE INDEX IF NOT EXISTS time ON messages (time)", ];