Class SherlockMigrator


  • public final class SherlockMigrator
    extends java.lang.Object
    Migration mechanism based on Sherlock distributed locks.

    It can be used to perform one way database migrations.

    Migration rules:

    • migrations must not run in parallel
    • migration change sets are applied in order
    • migration change sets must be run only once per all migrations
    • migration process stops after first change set failure
    • Constructor Detail

      • SherlockMigrator

        public SherlockMigrator​(Sherlock sherlock)
        Parameters:
        sherlock - sherlock used to manage migration locks
      • SherlockMigrator

        public SherlockMigrator​(java.lang.String migrationId,
                                Sherlock sherlock)
        Parameters:
        migrationId - id used as lock id for the whole migration process
        sherlock - sherlock used to manage migration locks
    • Method Detail

      • addChangeSet

        public SherlockMigrator addChangeSet​(java.lang.String changeSetId,
                                             java.lang.Runnable changeSet)
        Adds change set to migration process.
        Parameters:
        changeSetId - unique change set id used. This is is used as a lock id in migration process.
        changeSet - change set action that should be run if change set was not already applied
        Returns:
        the migrator