Handle v2.1.1 for SQLite and RethinkDB (#43)

This commit is contained in:
Daniel J. Summers 2024-03-28 22:17:09 -04:00
parent 6d8c73186c
commit 7499ce4c2d
2 changed files with 20 additions and 0 deletions

View File

@ -238,6 +238,12 @@ type RethinkDbData(conn: Net.IConnection, config: DataConfig, log: ILogger<Rethi
do! setDbVersion "v2.1" 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 /// Migrate data between versions
let migrate version = backgroundTask { let migrate version = backgroundTask {
let mutable v = defaultArg version "" let mutable v = defaultArg version ""
@ -254,6 +260,10 @@ type RethinkDbData(conn: Net.IConnection, config: DataConfig, log: ILogger<Rethi
do! migrateV2ToV2point1 () do! migrateV2ToV2point1 ()
v <- "v2.1" v <- "v2.1"
if v = "v2.1" then
do! migrateV2ToV2point1point1 ()
v <- "v2.1.1"
if v <> Utils.Migration.currentDbVersion then if v <> Utils.Migration.currentDbVersion then
log.LogWarning $"Unknown database version; assuming {Utils.Migration.currentDbVersion}" log.LogWarning $"Unknown database version; assuming {Utils.Migration.currentDbVersion}"
do! setDbVersion 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 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) /// Migrate data among versions (up only)
let migrate version = backgroundTask { let migrate version = backgroundTask {
let mutable v = defaultArg version "" let mutable v = defaultArg version ""
@ -446,6 +452,10 @@ type SQLiteData(conn: SqliteConnection, log: ILogger<SQLiteData>, ser: JsonSeria
do! migrateV2ToV2point1 () do! migrateV2ToV2point1 ()
v <- "v2.1" v <- "v2.1"
if v = "v2.1" then
do! migrateV2ToV2point1point1 ()
v <- "v2.1.1"
if v <> Utils.Migration.currentDbVersion then if v <> Utils.Migration.currentDbVersion then
log.LogWarning $"Unknown database version; assuming {Utils.Migration.currentDbVersion}" log.LogWarning $"Unknown database version; assuming {Utils.Migration.currentDbVersion}"
do! setDbVersion Utils.Migration.currentDbVersion do! setDbVersion Utils.Migration.currentDbVersion