Skip to content

Commit

Permalink
chore: adding migration script adding i_query index (#2578)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmer authored Apr 15, 2024
1 parent a04e0d9 commit 4117fe6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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;
"""
3 changes: 2 additions & 1 deletion migrations/message_store_postgres/pg_migration_manager.nim
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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] =
Expand Down
2 changes: 1 addition & 1 deletion waku/waku_archive/driver/postgres_driver/migrations.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion waku/waku_archive/driver/sqlite_driver/sqlite_driver.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 4117fe6

Please sign in to comment.