Fix schema migrations

This commit is contained in:
Michael Sproul
2026-04-01 10:10:48 +11:00
parent 993cecee83
commit 1ee2ce4258
4 changed files with 74 additions and 52 deletions

View File

@@ -22,13 +22,13 @@ pub fn migrate_schema<T: BeaconChainTypes>(
(_, _) if from == to && to == CURRENT_SCHEMA_VERSION => Ok(()),
// Upgrade from v28 to v29.
(SchemaVersion(28), SchemaVersion(29)) => {
upgrade_to_v29::<T>(&db)?;
db.store_schema_version_atomically(to, vec![])
let ops = upgrade_to_v29::<T>(&db)?;
db.store_schema_version_atomically(to, ops)
}
// Downgrade from v29 to v28.
(SchemaVersion(29), SchemaVersion(28)) => {
downgrade_from_v29::<T>(&db)?;
db.store_schema_version_atomically(to, vec![])
let ops = downgrade_from_v29::<T>(&db)?;
db.store_schema_version_atomically(to, ops)
}
// Anything else is an error.
(_, _) => Err(HotColdDBError::UnsupportedSchemaVersion {