Implement DB changes

This commit is contained in:
Michael Sproul
2022-07-18 17:52:22 +10:00
parent 092d228078
commit f0fa5a1618
6 changed files with 135 additions and 76 deletions

View File

@@ -1,4 +1,5 @@
//! Utilities for managing database schema changes.
mod migration_schema_v11;
mod migration_schema_v6;
mod migration_schema_v7;
mod migration_schema_v8;
@@ -130,6 +131,16 @@ pub fn migrate_schema<T: BeaconChainTypes>(
migration_schema_v9::downgrade_from_v9::<T>(db.clone(), log)?;
db.store_schema_version(to)
}
// Upgrade from v9 to v11 to store richer metadata in the attestation op pool.
(SchemaVersion(9), SchemaVersion(11)) => {
let ops = migration_schema_v11::upgrade_to_v11::<T>(db.clone(), log)?;
db.store_schema_version_atomically(to, ops)
}
// Downgrade from v11 to v9 to drop richer metadata from the attestation op pool.
(SchemaVersion(11), SchemaVersion(9)) => {
let ops = migration_schema_v11::downgrade_from_v11::<T>(db.clone(), log)?;
db.store_schema_version_atomically(to, ops)
}
// Anything else is an error.
(_, _) => Err(HotColdDBError::UnsupportedSchemaVersion {
target_version: to,