Implement DB upgrade migration

This commit is contained in:
Michael Sproul
2022-03-10 15:31:32 +11:00
parent 0ee31a0a69
commit b4c60807dd
6 changed files with 258 additions and 19 deletions

View File

@@ -1,4 +1,5 @@
//! Utilities for managing database schema changes.
mod migration_schema_v10;
mod migration_schema_v6;
mod migration_schema_v7;
mod migration_schema_v8;
@@ -181,6 +182,15 @@ pub fn migrate_schema<T: BeaconChainTypes>(
Ok(())
}
// Reserved for merge-related changes.
(SchemaVersion(8), SchemaVersion(9)) => Ok(()),
// Upgrade for tree-states database changes.
(SchemaVersion(9), SchemaVersion(10)) => migration_schema_v10::upgrade_to_v10::<T>(db, log),
// Downgrade for tree-states database changes.
(SchemaVersion(10), SchemaVersion(8)) => {
// FIXME(sproul): implement downgrade
panic!("downgrade not implemented yet")
}
// Anything else is an error.
(_, _) => Err(HotColdDBError::UnsupportedSchemaVersion {
target_version: to,