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 Detail

      • 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 scripts MigrationScript.migrate(Context) method. This way the script can call VersionAgnosticEmbeddedStorageManager.store(Object) or another method on the storage manager.
        root - is relayed to the scripts MigrationScript.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 scripts MigrationScript.migrate(Context) method. This way the script can call EmbeddedStorageManager#store or another method on the storage manager.
        objectToMigrate - is relayed to the scripts MigrationScript.migrate(Context) method. This way the script can change something within the object to migrate.
        Returns:
        the target version of the last executed script