mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Fix schema version jump
This commit is contained in:
@@ -26,6 +26,12 @@ pub fn migrate_schema<T: BeaconChainTypes>(
|
|||||||
match (from, to) {
|
match (from, to) {
|
||||||
// Migrating from the current schema version to iself is always OK, a no-op.
|
// Migrating from the current schema version to iself is always OK, a no-op.
|
||||||
(_, _) if from == to && to == CURRENT_SCHEMA_VERSION => Ok(()),
|
(_, _) if from == to && to == CURRENT_SCHEMA_VERSION => Ok(()),
|
||||||
|
// Upgrade for tree-states database changes.
|
||||||
|
(SchemaVersion(9), SchemaVersion(20)) => migration_schema_v20::upgrade_to_v20::<T>(db, log),
|
||||||
|
// Downgrade for tree-states database changes.
|
||||||
|
(SchemaVersion(20), SchemaVersion(9)) => {
|
||||||
|
migration_schema_v20::downgrade_from_v20::<T>(db, log)
|
||||||
|
}
|
||||||
// Upgrade across multiple versions by recursively migrating one step at a time.
|
// Upgrade across multiple versions by recursively migrating one step at a time.
|
||||||
(_, _) if from.as_u64() + 1 < to.as_u64() => {
|
(_, _) if from.as_u64() + 1 < to.as_u64() => {
|
||||||
let next = SchemaVersion(from.as_u64() + 1);
|
let next = SchemaVersion(from.as_u64() + 1);
|
||||||
@@ -128,12 +134,6 @@ pub fn migrate_schema<T: BeaconChainTypes>(
|
|||||||
migration_schema_v9::downgrade_from_v9::<T>(db.clone(), log)?;
|
migration_schema_v9::downgrade_from_v9::<T>(db.clone(), log)?;
|
||||||
db.store_schema_version(to)
|
db.store_schema_version(to)
|
||||||
}
|
}
|
||||||
// Upgrade for tree-states database changes.
|
|
||||||
(SchemaVersion(9), SchemaVersion(20)) => migration_schema_v20::upgrade_to_v20::<T>(db, log),
|
|
||||||
// Downgrade for tree-states database changes.
|
|
||||||
(SchemaVersion(20), SchemaVersion(9)) => {
|
|
||||||
migration_schema_v20::downgrade_from_v20::<T>(db, log)
|
|
||||||
}
|
|
||||||
// Anything else is an error.
|
// Anything else is an error.
|
||||||
(_, _) => Err(HotColdDBError::UnsupportedSchemaVersion {
|
(_, _) => Err(HotColdDBError::UnsupportedSchemaVersion {
|
||||||
target_version: to,
|
target_version: to,
|
||||||
|
|||||||
Reference in New Issue
Block a user