diff --git a/migrations/message_store/00010_dropStoredAt.up.sql b/migrations/message_store/00010_dropStoredAt.up.sql new file mode 100644 index 0000000000..4ef60dbd06 --- /dev/null +++ b/migrations/message_store/00010_dropStoredAt.up.sql @@ -0,0 +1,3 @@ +ALTER TABLE message DROP COLUMN timestamp; + +ALTER TABLE message RENAME COLUMN storedAt TO timestamp; \ No newline at end of file diff --git a/tests/waku_archive/archive_utils.nim b/tests/waku_archive/archive_utils.nim index affca9f78d..48e23f41d2 100644 --- a/tests/waku_archive/archive_utils.nim +++ b/tests/waku_archive/archive_utils.nim @@ -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() diff --git a/tests/waku_archive_legacy/archive_utils.nim b/tests/waku_archive_legacy/archive_utils.nim index 5fb17614df..8df0f5d7fb 100644 --- a/tests/waku_archive_legacy/archive_utils.nim +++ b/tests/waku_archive_legacy/archive_utils.nim @@ -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() diff --git a/waku/common/databases/db_sqlite.nim b/waku/common/databases/db_sqlite.nim index 26d2d955ee..2eaf5f4ec4 100644 --- a/waku/common/databases/db_sqlite.nim +++ b/waku/common/databases/db_sqlite.nim @@ -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() diff --git a/waku/waku_archive/driver/sqlite_driver/migrations.nim b/waku/waku_archive/driver/sqlite_driver/migrations.nim index 4c25ddf3c8..16ef9467b1 100644 --- a/waku/waku_archive/driver/sqlite_driver/migrations.nim +++ b/waku/waku_archive/driver/sqlite_driver/migrations.nim @@ -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] / ".." / ".." / ".." / ".."