Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

### Changed

- [#5452](https://github.com/ChainSafe/forest/pull/5452) Speed up void database migration.

### Removed

- [#5449](https://github.com/ChainSafe/forest/pull/5449) Remove unnecessary/duplicate metrics.
Expand Down
25 changes: 13 additions & 12 deletions src/db/migration/db_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,33 +65,34 @@ impl DbMigration {
let latest_db_version = get_latest_versioned_database(&self.chain_data_path())?
.unwrap_or_else(|| FOREST_VERSION.clone());

info!(
"Migrating database from version {} to {}",
latest_db_version, *FOREST_VERSION
);

let target_db_version = &FOREST_VERSION;

let migrations = create_migration_chain(&latest_db_version, target_db_version)?;

for migration in migrations {
info!(
"Migrating database from version {} to {}",
migration.from(),
migration.to()
);
let start = std::time::Instant::now();
migration.migrate(&self.chain_data_path(), &self.config)?;
info!(
"Successfully migrated from version {} to {}, took {}",
migration.from(),
migration.to(),
humantime::format_duration(std::time::Instant::now() - start),
);
}

info!(
"Migration to version {} complete",
target_db_version.to_string()
);

Ok(())
}
}

#[cfg(test)]
mod tests {
use crate::db::db_mode::FOREST_DB_DEV_MODE;

use super::*;
use crate::db::db_mode::FOREST_DB_DEV_MODE;

#[test]
fn test_migration_not_required_no_chain_path() {
Expand Down
Loading
Loading