pub(super) trait MigrationOperation {
// Required methods
fn new(from: Version, to: Version) -> Self
where Self: Sized;
fn from(&self) -> &Version;
fn to(&self) -> &Version;
fn migrate_core(
&self,
chain_data_path: &Path,
config: &Config,
) -> Result<PathBuf>;
// Provided methods
fn pre_checks(&self, chain_data_path: &Path) -> Result<()> { ... }
fn migrate(&self, chain_data_path: &Path, config: &Config) -> Result<()> { ... }
fn post_checks(&self, chain_data_path: &Path) -> Result<()> { ... }
}Expand description
Migration trait. It is expected that the MigrationOperation::migrate method will pick up the relevant database
existing under chain_data_path and create a new migration database in the same directory.
Required Methods§
fn new(from: Version, to: Version) -> Selfwhere
Self: Sized,
Sourcefn migrate_core(
&self,
chain_data_path: &Path,
config: &Config,
) -> Result<PathBuf>
fn migrate_core( &self, chain_data_path: &Path, config: &Config, ) -> Result<PathBuf>
Performs the actual migration. All the logic should be implemented here. Ideally, the migration should use as little of the Forest codebase as possible to avoid potential issues with the migration code itself and having to update it in the future. Returns the path to the migrated database (which is not yet validated)
Provided Methods§
Sourcefn pre_checks(&self, chain_data_path: &Path) -> Result<()>
fn pre_checks(&self, chain_data_path: &Path) -> Result<()>
Performs pre-migration checks. This is the place to check if the database is in a valid
state and if the migration can be performed. Note that some of the higher-level checks
(like checking if the database exists) are performed by the [Migration].
fn migrate(&self, chain_data_path: &Path, config: &Config) -> Result<()>
Sourcefn post_checks(&self, chain_data_path: &Path) -> Result<()>
fn post_checks(&self, chain_data_path: &Path) -> Result<()>
Performs post-migration checks. This is the place to check if the migration database is ready to be used by Forest and renamed into a versioned database.
Implementors§
impl MigrationOperation for Migration0_22_0_0_22_1
Migrates the database from version 0.22.0 to 0.22.1
impl MigrationOperation for Migration0_25_3_0_26_0
Migrates the database from version 0.25.3 to 0.26.0