Interface MicroMigrater
-
- All Known Implementing Classes:
AbstractMigrater
,ExplicitMigrater
public interface MicroMigrater
Executes all the available scripts to migrate the datastore to a certain version.- Author:
- Johannes Rabauer
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.TreeSet<? extends MigrationScript<?,?>>
getSortedScripts()
MigrationVersion
migrateToNewest(MigrationVersion fromVersion, VersionAgnosticEmbeddedStorageManager storageManager, java.lang.Object root)
Executes all the scripts that are available to the migrater.MigrationVersion
migrateToVersion(MigrationVersion fromVersion, MigrationVersion targetVersion, VersionAgnosticEmbeddedStorageManager storageManager, java.lang.Object objectToMigrate)
Executes all the scripts that are available to the migrater until the given targetVersion is reached.
-
-
-
Method Detail
-
getSortedScripts
java.util.TreeSet<? extends MigrationScript<?,?>> getSortedScripts()
- Returns:
- all the contained
MigrationScript
s, sorted by theirMigrationVersion
ascending.
-
migrateToNewest
MigrationVersion migrateToNewest(MigrationVersion fromVersion, VersionAgnosticEmbeddedStorageManager storageManager, java.lang.Object root)
Executes all the scripts that are available to the migrater. Only scripts with a higher target version than the given fromVersion are executed.
Scripts are executed one after another from the lowest to the highest version.Example:
Current version is 1.0.0
Scripts for v1.1.0, v2.0.0 and v1.2.1 are available
Scripts are chain executed like v1.1.0 then v1.2.1 then v2.0.0- Parameters:
fromVersion
- is the current version of the datastore. Scripts for lower versions then the fromVersion are not executed.storageManager
- is relayed to the scriptsMigrationScript.migrate(Context)
method. This way the script can callVersionAgnosticEmbeddedStorageManager.store(Object)
or another method on the storage manager.root
- is relayed to the scriptsMigrationScript.migrate(Context)
method. This way the script can change something within the root object.- Returns:
- the target version of the last executed script
-
migrateToVersion
MigrationVersion migrateToVersion(MigrationVersion fromVersion, MigrationVersion targetVersion, VersionAgnosticEmbeddedStorageManager storageManager, java.lang.Object objectToMigrate)
Executes all the scripts that are available to the migrater until the given targetVersion is reached. Only scripts with a higher target version than the given fromVersion are executed.
Scripts are executed one after another from the lowest to the highest version.Example:
Current version is 1.0.0
Scripts for v1.1.0, v2.0.0 and v1.2.1 are available
Scripts are chain executed like v1.1.0 then v1.2.1 then v2.0.0- Parameters:
fromVersion
- is the current version of the datastore. Scripts for lower versions then the fromVersion are not executed.targetVersion
- is the highest allowed script version. Scripts which have a higher version won't be exectued.storageManager
- is relayed to the scriptsMigrationScript.migrate(Context)
method. This way the script can call EmbeddedStorageManager#store or another method on the storage manager.objectToMigrate
- is relayed to the scriptsMigrationScript.migrate(Context)
method. This way the script can change something within the object to migrate.- Returns:
- the target version of the last executed script
-
-