com.rinoto.migramongo.MongoMigrationScript Maven / Gradle / Ivy
Show all versions of migramongo-core Show documentation
package com.rinoto.migramongo;
import com.mongodb.client.MongoDatabase;
/**
* Interface that the migration scripts must implement.
*
* MigraMongo
will search for Spring Services implementing this interface, and will execute them when needed.
*
* @author rinoto
*/
public interface MongoMigrationScript {
/**
* Returns the MigrationInfo
object with the information needed on how to migrate the script (from
and to
versions)
*
* @return the migrationInfo
*/
MigrationInfo getMigrationInfo();
/**
* It performs the actual migration. This method will be called by MigraMongo
, and the status (ok, failed) will be written to the _migramongo
collection in the DB
*
* @param database mongodb to use
* @throws Exception any unexpected exception
*/
void migrate(MongoDatabase database) throws Exception;
/**
* If true, this MigrationScript has been included in the initial one.
*
* - If
true
in a fresh new installation with already existing MigrationScripts in code, this Script will be added to the History, but will not be executed, i.e. it will be marked as skipped, because its code is already contained in the initial one.
* - If
false
, the migration script will be executed normally in a new installation.
*
* Default is true
*
* @return true if the code of this script has already been included in the initial script
*/
default boolean includedInInitialMigrationScript() {
return true;
}
}