diff --git a/CHANGELOG.md b/CHANGELOG.md index cbdceab3..091f9dbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.0.1 + +* Fix for ExplicitMigrater without any scripts + ## 3.0.0 * Added support for EclipseStore v2 diff --git a/micro-migration/src/main/java/software/xdev/micromigration/versionagnostic/VersionAgnosticMigrationManager.java b/micro-migration/src/main/java/software/xdev/micromigration/versionagnostic/VersionAgnosticMigrationManager.java index b655376f..bac02369 100644 --- a/micro-migration/src/main/java/software/xdev/micromigration/versionagnostic/VersionAgnosticMigrationManager.java +++ b/micro-migration/src/main/java/software/xdev/micromigration/versionagnostic/VersionAgnosticMigrationManager.java @@ -154,7 +154,7 @@ public void migrate(final Object objectToMigrate) objectToMigrate ); // Update stored version, if needed - if(!versionAfterUpdate.equals(versionBeforeUpdate)) + if(versionAfterUpdate != null && !versionAfterUpdate.equals(versionBeforeUpdate)) { this.currentVersionSetter.accept(versionAfterUpdate); this.currentVersionStorer.accept(versionAfterUpdate); diff --git a/micro-migration/src/test/java/software/xdev/micromigration/eclipsestore/integration/MigrationScriptWithNullSourceVersionTest.java b/micro-migration/src/test/java/software/xdev/micromigration/eclipsestore/integration/MigrationScriptWithNullSourceVersionTest.java index 12fbb799..7bab91c8 100644 --- a/micro-migration/src/test/java/software/xdev/micromigration/eclipsestore/integration/MigrationScriptWithNullSourceVersionTest.java +++ b/micro-migration/src/test/java/software/xdev/micromigration/eclipsestore/integration/MigrationScriptWithNullSourceVersionTest.java @@ -88,6 +88,32 @@ void updateFromEmptyVersion(@TempDir final Path storageFolder) } } + @Test + void updateWithNoScripts(@TempDir final Path storageFolder) + { + // First run without any migration script + try(final EmbeddedStorageManager storageManager = this.startEmbeddedStorageManagerWithPath(storageFolder)) + { + final EmptyVersionedRoot firstRoot = new EmptyVersionedRoot(); + storageManager.setRoot(firstRoot); + storageManager.storeRoot(); + assertNull(firstRoot.getVersion()); + } + + try(final EmbeddedStorageManager storageManager = this.startEmbeddedStorageManagerWithPath(storageFolder)) + { + new MigrationManager( + (Versioned)storageManager.root(), + new ExplicitMigrater(), + storageManager + ) + .migrate(storageManager.root()); + @SuppressWarnings("unchecked") + final EmptyVersionedRoot currentRoot = (EmptyVersionedRoot)storageManager.root(); + assertNull(currentRoot.getVersion()); + } + } + private EmbeddedStorageManager startEmbeddedStorageManagerWithPath(final Path storageFolder) { return EmbeddedStorage.start(storageFolder);