chore: adding extra migration to sqlite and improving error message (#3240)

This commit is contained in:
gabrielmer 2025-01-16 16:10:28 +01:00 committed by GitHub
parent 9c0ad85179
commit bfd60ceab4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 4 deletions

View File

@ -0,0 +1,3 @@
ALTER TABLE message DROP COLUMN timestamp;
ALTER TABLE message RENAME COLUMN storedAt TO timestamp;

View File

@ -9,6 +9,7 @@ import
waku_archive,
waku_archive/common,
waku_archive/driver/sqlite_driver,
waku_archive/driver/sqlite_driver/migrations,
common/databases/db_sqlite,
],
../testlib/[wakucore]
@ -18,7 +19,8 @@ proc newSqliteDatabase*(path: Option[string] = string.none()): SqliteDatabase =
proc newSqliteArchiveDriver*(): ArchiveDriver =
let database = newSqliteDatabase()
SqliteDriver.new(database).tryGet()
migrate(database).tryGet()
return SqliteDriver.new(database).tryGet()
proc newWakuArchive*(driver: ArchiveDriver): WakuArchive =
WakuArchive.new(driver).get()

View File

@ -9,6 +9,7 @@ import
waku_archive_legacy,
waku_archive_legacy/common,
waku_archive_legacy/driver/sqlite_driver,
waku_archive_legacy/driver/sqlite_driver/migrations,
common/databases/db_sqlite,
],
../testlib/[wakucore]
@ -18,7 +19,8 @@ proc newSqliteDatabase*(path: Option[string] = string.none()): SqliteDatabase =
proc newSqliteArchiveDriver*(): ArchiveDriver =
let database = newSqliteDatabase()
SqliteDriver.new(database).tryGet()
migrate(database).tryGet()
return SqliteDriver.new(database).tryGet()
proc newWakuArchive*(driver: ArchiveDriver): WakuArchive =
WakuArchive.new(driver).get()

View File

@ -160,7 +160,7 @@ proc exec*[P](s: SqliteStmt[P, void], params: P): DatabaseResult[void] =
let res =
if (let v = sqlite3_step(s); v != SQLITE_DONE):
err($sqlite3_errstr(v))
err($sqlite3_errstr(v) & " " & $sqlite3_errmsg(sqlite3_db_handle(s)))
else:
ok()

View File

@ -7,7 +7,7 @@ import ../../../common/databases/db_sqlite, ../../../common/databases/common
logScope:
topics = "waku archive migration"
const SchemaVersion* = 9 # increase this when there is an update in the database schema
const SchemaVersion* = 10 # increase this when there is an update in the database schema
template projectRoot(): string =
currentSourcePath.rsplit(DirSep, 1)[0] / ".." / ".." / ".." / ".."