mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-06 03:54:54 +00:00
fix: avoid double db migration for sqlite (#3244)
This commit is contained in:
parent
122e0f32dd
commit
2ce2453545
@ -35,7 +35,8 @@ import
|
|||||||
../node/peer_manager/peer_store/migrations as peer_store_sqlite_migrations,
|
../node/peer_manager/peer_store/migrations as peer_store_sqlite_migrations,
|
||||||
../waku_lightpush/common,
|
../waku_lightpush/common,
|
||||||
../common/utils/parse_size_units,
|
../common/utils/parse_size_units,
|
||||||
../common/rate_limit/setting
|
../common/rate_limit/setting,
|
||||||
|
../common/databases/dburl
|
||||||
|
|
||||||
## Peer persistence
|
## Peer persistence
|
||||||
|
|
||||||
@ -267,8 +268,27 @@ proc setupProtocols(
|
|||||||
## then the legacy will be in charge of performing the archiving.
|
## then the legacy will be in charge of performing the archiving.
|
||||||
## Regarding storage, the only diff between the current/future archive driver and the legacy
|
## Regarding storage, the only diff between the current/future archive driver and the legacy
|
||||||
## one, is that the legacy stores an extra field: the id (message digest.)
|
## one, is that the legacy stores an extra field: the id (message digest.)
|
||||||
|
|
||||||
|
## TODO: remove this "migrate" variable once legacy store is removed
|
||||||
|
## It is now necessary because sqlite's legacy store has an extra field: storedAt
|
||||||
|
## This breaks compatibility between store's and legacy store's schemas in sqlite
|
||||||
|
## So for now, we need to make sure that when legacy store is enabled and we use sqlite
|
||||||
|
## that we migrate our db according to legacy store's schema to have the extra field
|
||||||
|
|
||||||
|
let engineRes = dburl.getDbEngine(conf.storeMessageDbUrl)
|
||||||
|
if engineRes.isErr():
|
||||||
|
return err("error getting db engine in setupProtocols: " & engineRes.error)
|
||||||
|
|
||||||
|
let engine = engineRes.get()
|
||||||
|
|
||||||
|
let migrate =
|
||||||
|
if engine == "sqlite" and conf.legacyStore:
|
||||||
|
false
|
||||||
|
else:
|
||||||
|
conf.storeMessageDbMigration
|
||||||
|
|
||||||
let archiveDriverRes = waitFor driver.ArchiveDriver.new(
|
let archiveDriverRes = waitFor driver.ArchiveDriver.new(
|
||||||
conf.storeMessageDbUrl, conf.storeMessageDbVacuum, conf.storeMessageDbMigration,
|
conf.storeMessageDbUrl, conf.storeMessageDbVacuum, migrate,
|
||||||
conf.storeMaxNumDbConnections, onFatalErrorAction,
|
conf.storeMaxNumDbConnections, onFatalErrorAction,
|
||||||
)
|
)
|
||||||
if archiveDriverRes.isErr():
|
if archiveDriverRes.isErr():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user