Merge pull request #3020 from ethcore/fix-old-migrations
apply post-consolidation migrations after consolidating
This commit is contained in:
commit
19d5f93745
@ -239,9 +239,11 @@ pub fn migrate(path: &Path, pruning: Algorithm, compaction_profile: CompactionPr
|
|||||||
// Perform pre-consolidation migrations
|
// Perform pre-consolidation migrations
|
||||||
if version < CONSOLIDATION_VERSION && exists(&legacy::blocks_database_path(path)) {
|
if version < CONSOLIDATION_VERSION && exists(&legacy::blocks_database_path(path)) {
|
||||||
println!("Migrating database from version {} to {}", version, CONSOLIDATION_VERSION);
|
println!("Migrating database from version {} to {}", version, CONSOLIDATION_VERSION);
|
||||||
try!(migrate_database(version, legacy::blocks_database_path(path), try!(legacy::blocks_database_migrations(&compaction_profile))));
|
|
||||||
try!(migrate_database(version, legacy::extras_database_path(path), try!(legacy::extras_database_migrations(&compaction_profile))));
|
try!(migrate_database(version, legacy::extras_database_path(path), try!(legacy::extras_database_migrations(&compaction_profile))));
|
||||||
try!(migrate_database(version, legacy::state_database_path(path), try!(legacy::state_database_migrations(pruning, &compaction_profile))));
|
try!(migrate_database(version, legacy::state_database_path(path), try!(legacy::state_database_migrations(pruning, &compaction_profile))));
|
||||||
|
try!(migrate_database(version, legacy::blocks_database_path(path), try!(legacy::blocks_database_migrations(&compaction_profile))));
|
||||||
|
|
||||||
let db_path = consolidated_database_path(path);
|
let db_path = consolidated_database_path(path);
|
||||||
// Remove the database dir (it shouldn't exist anyway, but it might when migration was interrupted)
|
// Remove the database dir (it shouldn't exist anyway, but it might when migration was interrupted)
|
||||||
let _ = fs::remove_dir_all(db_path.clone());
|
let _ = fs::remove_dir_all(db_path.clone());
|
||||||
@ -257,6 +259,9 @@ pub fn migrate(path: &Path, pruning: Algorithm, compaction_profile: CompactionPr
|
|||||||
println!("Migration finished");
|
println!("Migration finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update version so we can apply post-consolidation migrations.
|
||||||
|
let version = ::std::cmp::max(CONSOLIDATION_VERSION, version);
|
||||||
|
|
||||||
// Further migrations
|
// Further migrations
|
||||||
if version >= CONSOLIDATION_VERSION && version < CURRENT_VERSION && exists(&consolidated_database_path(path)) {
|
if version >= CONSOLIDATION_VERSION && version < CURRENT_VERSION && exists(&consolidated_database_path(path)) {
|
||||||
println!("Migrating database from version {} to {}", ::std::cmp::max(CONSOLIDATION_VERSION, version), CURRENT_VERSION);
|
println!("Migrating database from version {} to {}", ::std::cmp::max(CONSOLIDATION_VERSION, version), CURRENT_VERSION);
|
||||||
|
@ -251,6 +251,7 @@ impl Manager {
|
|||||||
let mut cur_db = Arc::new(try!(Database::open(&db_config, old_path_str).map_err(Error::Custom)));
|
let mut cur_db = Arc::new(try!(Database::open(&db_config, old_path_str).map_err(Error::Custom)));
|
||||||
|
|
||||||
for migration in migrations {
|
for migration in migrations {
|
||||||
|
trace!(target: "migration", "starting migration to version {}", migration.version());
|
||||||
// Change number of columns in new db
|
// Change number of columns in new db
|
||||||
let current_columns = db_config.columns;
|
let current_columns = db_config.columns;
|
||||||
db_config.columns = migration.columns();
|
db_config.columns = migration.columns();
|
||||||
|
Loading…
Reference in New Issue
Block a user