mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 21:08:32 +00:00
With LH v8.1.3 supporting Fulu-on-Gnosis, we no longer need these DB migrations. All Lighthouse nodes running in prod will soon be updated to LH v8.0.0+ and schema v28+. This PR helps with Gloas fork choice changes, by allowing us to avoid updating old schema migrations when adding V29 for Gloas: - https://github.com/sigp/lighthouse/pull/9025 Co-Authored-By: Michael Sproul <michael@sigmaprime.io>
28 lines
1.1 KiB
Rust
28 lines
1.1 KiB
Rust
//! Utilities for managing database schema changes.
|
|
use crate::beacon_chain::BeaconChainTypes;
|
|
use std::sync::Arc;
|
|
use store::Error as StoreError;
|
|
use store::hot_cold_store::{HotColdDB, HotColdDBError};
|
|
use store::metadata::{CURRENT_SCHEMA_VERSION, SchemaVersion};
|
|
|
|
/// Migrate the database from one schema version to another, applying all requisite mutations.
|
|
///
|
|
/// All migrations for schema versions up to and including v28 have been removed. Nodes on live
|
|
/// networks are already running v28, so only the current version check remains.
|
|
pub fn migrate_schema<T: BeaconChainTypes>(
|
|
_db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>,
|
|
from: SchemaVersion,
|
|
to: SchemaVersion,
|
|
) -> Result<(), StoreError> {
|
|
match (from, to) {
|
|
// Migrating from the current schema version to itself is always OK, a no-op.
|
|
(_, _) if from == to && to == CURRENT_SCHEMA_VERSION => Ok(()),
|
|
// Anything else is an error.
|
|
(_, _) => Err(HotColdDBError::UnsupportedSchemaVersion {
|
|
target_version: to,
|
|
current_version: from,
|
|
}
|
|
.into()),
|
|
}
|
|
}
|