Dont upgrade for old versions of DB (#54)

This commit is contained in:
rakita 2020-09-23 13:49:25 +02:00 committed by GitHub
parent 27a0142af1
commit 25c2f7e7fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,6 +48,8 @@ pub const TO_V12: ChangeColumns = ChangeColumns {
const DEFAULT_VERSION: u32 = 5; const DEFAULT_VERSION: u32 = 5;
/// Current version of database models. /// Current version of database models.
const CURRENT_VERSION: u32 = 16; const CURRENT_VERSION: u32 = 16;
/// Until this version please use upgrade tool.
const USE_MIGRATION_TOOL: u32 = 15;
/// A version of database at which blooms-db was introduced /// A version of database at which blooms-db was introduced
const BLOOMS_DB_VERSION: u32 = 13; const BLOOMS_DB_VERSION: u32 = 13;
/// Defines how many items are migrated to the new version of database at once. /// Defines how many items are migrated to the new version of database at once.
@ -64,6 +66,8 @@ pub enum Error {
FutureDBVersion, FutureDBVersion,
/// Migration is not possible. /// Migration is not possible.
MigrationImpossible, MigrationImpossible,
/// For old versions use external migration tool
UseMigrationTool,
/// Blooms-db migration error. /// Blooms-db migration error.
BloomsDB(ethcore::error::Error), BloomsDB(ethcore::error::Error),
/// Migration was completed succesfully, /// Migration was completed succesfully,
@ -77,7 +81,8 @@ impl Display for Error {
Error::UnknownDatabaseVersion => "Current database version cannot be read".into(), Error::UnknownDatabaseVersion => "Current database version cannot be read".into(),
Error::FutureDBVersion => "Database was created with newer client version. Upgrade your client or delete DB and resync.".into(), Error::FutureDBVersion => "Database was created with newer client version. Upgrade your client or delete DB and resync.".into(),
Error::MigrationImpossible => format!("Database migration to version {} is not possible.", CURRENT_VERSION), Error::MigrationImpossible => format!("Database migration to version {} is not possible.", CURRENT_VERSION),
Error::BloomsDB(ref err) => format!("blooms-db migration error: {}", err), Error::BloomsDB(ref err) => format!("blooms-db migration error: {}", err),
Error::UseMigrationTool => "For db versions 15 and lower (v2.5.13=>13, 2.7.2=>14, v3.0.1=>15) please use upgrade db tool to manually upgrade db: https://github.com/openethereum/3.1-db-upgrade-tool".into(),
Error::Io(ref err) => format!("Unexpected io error on DB migration: {}.", err), Error::Io(ref err) => format!("Unexpected io error on DB migration: {}.", err),
}; };
@ -219,6 +224,10 @@ pub fn migrate(path: &Path, compaction_profile: &DatabaseCompactionProfile) -> R
return Ok(()); return Ok(());
} }
if version <= USE_MIGRATION_TOOL {
return Err(Error::UseMigrationTool);
}
let db_path = consolidated_database_path(path); let db_path = consolidated_database_path(path);
// Further migrations // Further migrations