Package com.coditory.sherlock
Class SherlockMigrator
java.lang.Object
com.coditory.sherlock.SherlockMigrator
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
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionSherlockMigrator
(Sherlock sherlock) SherlockMigrator
(String migrationId, Sherlock sherlock) -
Method Summary
Modifier and TypeMethodDescriptionaddChangeSet
(String changeSetId, Runnable changeSet) Adds change set to migration process.migrate()
Runs the migration process.
-
Constructor Details
-
SherlockMigrator
- Parameters:
sherlock
- sherlock used to manage migration locks
-
SherlockMigrator
- Parameters:
migrationId
- id used as lock id for the whole migration processsherlock
- sherlock used to manage migration locks
-
-
Method Details
-
addChangeSet
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
-
migrate
Runs the migration process.- Returns:
- migration result
-