mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-24 05:39:21 +00:00
560f949a8b
* Add postgres_driver/migrations.nim * Postgres and archive logic adaptation to the migration implementation * libwaku: adapt node_lifecycle_request.nim to migration refactoring * test_app.nim: add more detail for test that only fails in CI * postgres migrations: store the migration scripts inside the resulting wakunode binary instead of external .sql files.
38 lines
847 B
Nim
38 lines
847 B
Nim
|
|
import
|
|
content_script_version_1,
|
|
content_script_version_2
|
|
|
|
type
|
|
MigrationScript* = object
|
|
version*: int
|
|
scriptContent*: string
|
|
|
|
proc init*(T: type MigrationScript,
|
|
targetVersion: int,
|
|
scriptContent: string): T =
|
|
|
|
return MigrationScript(
|
|
targetVersion: targetVersion,
|
|
scriptContent: scriptContent)
|
|
|
|
const PgMigrationScripts* = @[
|
|
MigrationScript(
|
|
version: 1,
|
|
scriptContent: ContentScriptVersion_1),
|
|
MigrationScript(
|
|
version: 2,
|
|
scriptContent: ContentScriptVersion_2)
|
|
]
|
|
|
|
proc getMigrationScripts*(currentVersion: int64,
|
|
targetVersion: int64): seq[string] =
|
|
var ret = newSeq[string]()
|
|
var v = currentVersion
|
|
while v < targetVersion:
|
|
ret.add(PgMigrationScripts[v].scriptContent)
|
|
v.inc()
|
|
return ret
|
|
|
|
|