diff --git a/ethcore/src/migrations/mod.rs b/ethcore/src/migrations/mod.rs
index b9a00a15e..6cc4a13a8 100644
--- a/ethcore/src/migrations/mod.rs
+++ b/ethcore/src/migrations/mod.rs
@@ -28,4 +28,4 @@ mod v10;
pub use self::v10::ToV10;
mod v11;
-pub use self::v11::ToV11;
+pub use self::v11::TO_V11;
diff --git a/ethcore/src/migrations/v11.rs b/ethcore/src/migrations/v11.rs
index 8795cf364..e33de6170 100644
--- a/ethcore/src/migrations/v11.rs
+++ b/ethcore/src/migrations/v11.rs
@@ -14,33 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see .
-
//! Adds a seventh column for node information.
-use util::kvdb::Database;
-use util::migration::{Batch, Config, Error, Migration, Progress};
-use std::sync::Arc;
+use util::migration::ChangeColumns;
-/// Copies over data for all existing columns.
-#[derive(Default)]
-pub struct ToV11(Progress);
-
-
-impl Migration for ToV11 {
- fn pre_columns(&self) -> Option { Some(6) }
- fn columns(&self) -> Option { Some(7) }
-
- fn version(&self) -> u32 { 11 }
-
- fn migrate(&mut self, source: Arc, config: &Config, dest: &mut Database, col: Option) -> Result<(), Error> {
- // just copy everything over.
- let mut batch = Batch::new(config, col);
-
- for (key, value) in source.iter(col) {
- self.0.tick();
- batch.insert(key.to_vec(), value.to_vec(), dest)?
- }
-
- batch.commit(dest)
- }
-}
+/// The migration from v10 to v11.
+pub const TO_V11: ChangeColumns = ChangeColumns {
+ pre_columns: Some(6),
+ post_columns: Some(7),
+ version: 11,
+};
diff --git a/parity/migration.rs b/parity/migration.rs
index c2d5c0797..797e8d2d6 100644
--- a/parity/migration.rs
+++ b/parity/migration.rs
@@ -146,7 +146,7 @@ pub fn default_migration_settings(compaction_profile: &CompactionProfile) -> Mig
fn consolidated_database_migrations(compaction_profile: &CompactionProfile) -> Result {
let mut manager = MigrationManager::new(default_migration_settings(compaction_profile));
manager.add_migration(migrations::ToV10::new()).map_err(|_| Error::MigrationImpossible)?;
- manager.add_migration(migrations::ToV11::default()).map_err(|_| Error::MigrationImpossible)?;
+ manager.add_migration(migrations::TO_V11).map_err(|_| Error::MigrationImpossible)?;
Ok(manager)
}
diff --git a/util/src/migration/mod.rs b/util/src/migration/mod.rs
index 3af86fc5b..3f0a7a806 100644
--- a/util/src/migration/mod.rs
+++ b/util/src/migration/mod.rs
@@ -167,6 +167,23 @@ impl Migration for T {
}
}
+/// An even simpler migration which just changes the number of columns.
+pub struct ChangeColumns {
+ pub pre_columns: Option,
+ pub post_columns: Option,
+ pub version: u32,
+}
+
+impl Migration for ChangeColumns {
+ fn pre_columns(&self) -> Option { self.pre_columns }
+ fn columns(&self) -> Option { self.post_columns }
+ fn version(&self) -> u32 { self.version }
+ fn alters_existing(&self) -> bool { false }
+ fn migrate(&mut self, _: Arc, _: &Config, _: &mut Database, _: Option) -> Result<(), Error> {
+ Ok(())
+ }
+}
+
/// Get the path where all databases reside.
fn database_path(path: &Path) -> PathBuf {
let mut temp_path = path.to_owned();