Fix PostgreSQL v2.1 migration #44

Merged
danieljsummers merged 2 commits from issue-43 into main 2024-03-29 02:25:10 +00:00
2 changed files with 20 additions and 0 deletions
Showing only changes of commit 7499ce4c2d - Show all commits

View File

@ -238,6 +238,12 @@ type RethinkDbData(conn: Net.IConnection, config: DataConfig, log: ILogger<Rethi
do! setDbVersion "v2.1"
}
/// Migrate from v2.1 to v2.1.1
let migrateV2ToV2point1point1 () = backgroundTask {
Utils.Migration.logStep log "v2.1 to v2.1.1" "Setting database version; no migration required"
do! setDbVersion "v2.1.1"
}
/// Migrate data between versions
let migrate version = backgroundTask {
let mutable v = defaultArg version ""
@ -254,6 +260,10 @@ type RethinkDbData(conn: Net.IConnection, config: DataConfig, log: ILogger<Rethi
do! migrateV2ToV2point1 ()
v <- "v2.1"
if v = "v2.1" then
do! migrateV2ToV2point1point1 ()
v <- "v2.1.1"
if v <> Utils.Migration.currentDbVersion then
log.LogWarning $"Unknown database version; assuming {Utils.Migration.currentDbVersion}"
do! setDbVersion Utils.Migration.currentDbVersion

View File

@ -430,6 +430,12 @@ type SQLiteData(conn: SqliteConnection, log: ILogger<SQLiteData>, ser: JsonSeria
Utils.Migration.backupAndRestoreRequired log "v2" "v2.1" webLogs
}
/// Migrate from v2.1 to v2.1.1
let migrateV2ToV2point1point1 () = backgroundTask {
Utils.Migration.logStep log "v2.1 to v2.1.1" "Setting database version; no migration required"
do! setDbVersion "v2.1.1"
}
/// Migrate data among versions (up only)
let migrate version = backgroundTask {
let mutable v = defaultArg version ""
@ -446,6 +452,10 @@ type SQLiteData(conn: SqliteConnection, log: ILogger<SQLiteData>, ser: JsonSeria
do! migrateV2ToV2point1 ()
v <- "v2.1"
if v = "v2.1" then
do! migrateV2ToV2point1point1 ()
v <- "v2.1.1"
if v <> Utils.Migration.currentDbVersion then
log.LogWarning $"Unknown database version; assuming {Utils.Migration.currentDbVersion}"
do! setDbVersion Utils.Migration.currentDbVersion