mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-02 05:53:11 +00:00
chore: adding extra migration to sqlite and improving error message (#3240)
This commit is contained in:
parent
192db550c9
commit
4d9e11f16b
3
migrations/message_store/00010_dropStoredAt.up.sql
Normal file
3
migrations/message_store/00010_dropStoredAt.up.sql
Normal file
@ -0,0 +1,3 @@
|
||||
ALTER TABLE message DROP COLUMN timestamp;
|
||||
|
||||
ALTER TABLE message RENAME COLUMN storedAt TO timestamp;
|
||||
@ -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()
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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()
|
||||
|
||||
|
||||
@ -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] / ".." / ".." / ".." / ".."
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user