add new index to optimize the order by storedAt (#2778)

This commit is contained in:
Ivan FB 2024-06-06 11:38:58 +02:00 committed by GitHub
parent 24661ea969
commit 3a93437300
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 2 deletions

View File

@ -0,0 +1,6 @@
const ContentScriptVersion_5* =
"""
CREATE INDEX IF NOT EXISTS i_query_storedAt ON messages (storedAt, id);
UPDATE version SET version = 5 WHERE version = 4;
"""

View File

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

View File

@ -9,7 +9,7 @@ import
logScope: logScope:
topics = "waku archive migration" topics = "waku archive migration"
const SchemaVersion* = 4 # increase this when there is an update in the database schema const SchemaVersion* = 5 # 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