mirror of https://github.com/waku-org/nwaku.git
chore: adding migration script adding i_query index (#2578)
This commit is contained in:
parent
a04e0d9971
commit
4117fe65b7
|
@ -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;
|
||||||
|
|
||||||
|
"""
|
|
@ -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
|
type MigrationScript* = object
|
||||||
version*: int
|
version*: int
|
||||||
|
@ -11,6 +11,7 @@ const PgMigrationScripts* =
|
||||||
@[
|
@[
|
||||||
MigrationScript(version: 1, scriptContent: ContentScriptVersion_1),
|
MigrationScript(version: 1, scriptContent: ContentScriptVersion_1),
|
||||||
MigrationScript(version: 2, scriptContent: ContentScriptVersion_2),
|
MigrationScript(version: 2, scriptContent: ContentScriptVersion_2),
|
||||||
|
MigrationScript(version: 3, scriptContent: ContentScriptVersion_3),
|
||||||
]
|
]
|
||||||
|
|
||||||
proc getMigrationScripts*(currentVersion: int64, targetVersion: int64): seq[string] =
|
proc getMigrationScripts*(currentVersion: int64, targetVersion: int64): seq[string] =
|
||||||
|
|
|
@ -9,7 +9,7 @@ import
|
||||||
logScope:
|
logScope:
|
||||||
topics = "waku archive migration"
|
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] =
|
proc breakIntoStatements*(script: string): seq[string] =
|
||||||
## Given a full migration script, that can potentially contain a list
|
## Given a full migration script, that can potentially contain a list
|
||||||
|
|
|
@ -35,7 +35,7 @@ proc init(db: SqliteDatabase): ArchiveDriverResult[void] =
|
||||||
|
|
||||||
let resMsgIndex = createHistoryQueryIndex(db)
|
let resMsgIndex = createHistoryQueryIndex(db)
|
||||||
if resMsgIndex.isErr():
|
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()
|
return ok()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue