chore: adding migration script adding i_query index (#2578)

This commit is contained in:
gabrielmer 2024-04-15 12:57:35 +03:00 committed by GitHub
parent a04e0d9971
commit 4117fe65b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 3 deletions

View File

@ -0,0 +1,8 @@
const ContentScriptVersion_3* =
"""
CREATE INDEX IF NOT EXISTS i_query ON messages
(contentTopic, pubsubTopic, storedAt, id);
UPDATE version SET version = 3 WHERE version = 2;
"""

View File

@ -1,4 +1,4 @@
import content_script_version_1, content_script_version_2
import content_script_version_1, content_script_version_2, content_script_version_3
type MigrationScript* = object
version*: int
@ -11,6 +11,7 @@ const PgMigrationScripts* =
@[
MigrationScript(version: 1, scriptContent: ContentScriptVersion_1),
MigrationScript(version: 2, scriptContent: ContentScriptVersion_2),
MigrationScript(version: 3, scriptContent: ContentScriptVersion_3),
]
proc getMigrationScripts*(currentVersion: int64, targetVersion: int64): seq[string] =

View File

@ -9,7 +9,7 @@ import
logScope:
topics = "waku archive migration"
const SchemaVersion* = 2 # increase this when there is an update in the database schema
const SchemaVersion* = 3 # increase this when there is an update in the database schema
proc breakIntoStatements*(script: string): seq[string] =
## Given a full migration script, that can potentially contain a list

View File

@ -35,7 +35,7 @@ proc init(db: SqliteDatabase): ArchiveDriverResult[void] =
let resMsgIndex = createHistoryQueryIndex(db)
if resMsgIndex.isErr():
return err("failed to create i_msg index: " & resMsgIndex.error())
return err("failed to create i_query index: " & resMsgIndex.error())
return ok()