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
This commit is contained in:
Reto Brunner 2022-12-29 14:35:57 +01:00
parent 86e376fc03
commit 3e7255ff20

View File

@ -25,12 +25,12 @@ try {
type Migration = {version: number; stmts: string[]}; 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 // Desired schema, adapt to the newest version and add migrations to the array below
const schema = [ const schema = [
"CREATE TABLE IF NOT EXISTS options (name TEXT, value TEXT, CONSTRAINT name_unique UNIQUE (name))", "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 network_channel ON messages (network, channel)",
"CREATE INDEX IF NOT EXISTS time ON messages (time)", "CREATE INDEX IF NOT EXISTS time ON messages (time)",
]; ];