|
35 | 35 | ../node/peer_manager/peer_store/migrations as peer_store_sqlite_migrations, |
36 | 36 | ../waku_lightpush/common, |
37 | 37 | ../common/utils/parse_size_units, |
38 | | - ../common/rate_limit/setting |
| 38 | + ../common/rate_limit/setting, |
| 39 | + ../common/databases/dburl |
39 | 40 |
|
40 | 41 | ## Peer persistence |
41 | 42 |
|
@@ -267,8 +268,27 @@ proc setupProtocols( |
267 | 268 | ## then the legacy will be in charge of performing the archiving. |
268 | 269 | ## Regarding storage, the only diff between the current/future archive driver and the legacy |
269 | 270 | ## one, is that the legacy stores an extra field: the id (message digest.) |
| 271 | + |
| 272 | + ## TODO: remove this "migrate" variable once legacy store is removed |
| 273 | + ## It is now necessary because sqlite's legacy store has an extra field: storedAt |
| 274 | + ## This breaks compatibility between store's and legacy store's schemas in sqlite |
| 275 | + ## So for now, we need to make sure that when legacy store is enabled and we use sqlite |
| 276 | + ## that we migrate our db according to legacy store's schema to have the extra field |
| 277 | + |
| 278 | + let engineRes = dburl.getDbEngine(conf.storeMessageDbUrl) |
| 279 | + if engineRes.isErr(): |
| 280 | + return err("error getting db engine in setupProtocols: " & engineRes.error) |
| 281 | + |
| 282 | + let engine = engineRes.get() |
| 283 | + |
| 284 | + let migrate = |
| 285 | + if engine == "sqlite" and conf.legacyStore: |
| 286 | + false |
| 287 | + else: |
| 288 | + conf.storeMessageDbMigration |
| 289 | + |
270 | 290 | let archiveDriverRes = waitFor driver.ArchiveDriver.new( |
271 | | - conf.storeMessageDbUrl, conf.storeMessageDbVacuum, conf.storeMessageDbMigration, |
| 291 | + conf.storeMessageDbUrl, conf.storeMessageDbVacuum, migrate, |
272 | 292 | conf.storeMaxNumDbConnections, onFatalErrorAction, |
273 | 293 | ) |
274 | 294 | if archiveDriverRes.isErr(): |
|
0 commit comments