pub(super) trait MigrationOperation {
    // Required methods
    fn new(from: Version, to: Version) -> Self
       where Self: Sized;
    fn pre_checks(&self, chain_data_path: &Path) -> Result<()>;
    fn migrate(
        &self,
        chain_data_path: &Path,
        config: &Config,
    ) -> Result<PathBuf>;
    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§

source

fn new(from: Version, to: Version) -> Self
where Self: Sized,

source

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.

source

fn migrate(&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)

source

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§

source§

impl MigrationOperation for Migration0_12_1_0_13_0

Migrates the database from version 0.12.1 to 0.13.0 This migration is needed because the Settings column in the ParityDb table changed to binary-tree indexed and the data from HEAD and meta.yaml files was moved to the Settings column.

source§

impl MigrationOperation for Migration0_15_2_0_16_0

Migrates the database from version 0.15.2 to 0.16.0 This migration merges the two databases represented by rolling db into one.

source§

impl MigrationOperation for Migration0_18_0_0_19_0

Migrates the database from version 0.18.0 to 0.19.0

source§

impl MigrationOperation for MigrationVoid