2024-05-06 10:20:21 +02:00
|
|
|
import
|
|
|
|
content_script_version_1, content_script_version_2, content_script_version_3,
|
2024-07-12 12:19:12 -04:00
|
|
|
content_script_version_4, content_script_version_5, content_script_version_6
|
2024-03-01 12:05:27 +01:00
|
|
|
|
2024-03-16 00:08:47 +01:00
|
|
|
type MigrationScript* = object
|
|
|
|
version*: int
|
|
|
|
scriptContent*: string
|
2024-03-01 12:05:27 +01:00
|
|
|
|
2024-03-16 00:08:47 +01:00
|
|
|
proc init*(T: type MigrationScript, targetVersion: int, scriptContent: string): T =
|
|
|
|
return MigrationScript(targetVersion: targetVersion, scriptContent: scriptContent)
|
2024-03-01 12:05:27 +01:00
|
|
|
|
2024-03-16 00:08:47 +01:00
|
|
|
const PgMigrationScripts* =
|
|
|
|
@[
|
|
|
|
MigrationScript(version: 1, scriptContent: ContentScriptVersion_1),
|
|
|
|
MigrationScript(version: 2, scriptContent: ContentScriptVersion_2),
|
2024-04-15 12:57:35 +03:00
|
|
|
MigrationScript(version: 3, scriptContent: ContentScriptVersion_3),
|
2024-05-06 10:20:21 +02:00
|
|
|
MigrationScript(version: 4, scriptContent: ContentScriptVersion_4),
|
2024-06-06 11:38:58 +02:00
|
|
|
MigrationScript(version: 5, scriptContent: ContentScriptVersion_5),
|
2024-07-12 12:19:12 -04:00
|
|
|
MigrationScript(version: 6, scriptContent: ContentScriptVersion_6),
|
2024-03-16 00:08:47 +01:00
|
|
|
]
|
2024-03-01 12:05:27 +01:00
|
|
|
|
2024-03-16 00:08:47 +01:00
|
|
|
proc getMigrationScripts*(currentVersion: int64, targetVersion: int64): seq[string] =
|
2024-03-01 12:05:27 +01:00
|
|
|
var ret = newSeq[string]()
|
|
|
|
var v = currentVersion
|
|
|
|
while v < targetVersion:
|
|
|
|
ret.add(PgMigrationScripts[v].scriptContent)
|
|
|
|
v.inc()
|
|
|
|
return ret
|