@Target(value=TYPE) @Retention(value=RUNTIME) public @interface ChangeUnit
The main difference is that classes annotated with @ChangeUnit can only have one changeSet method, annotated with @Execution and optionally another changeSet annotated with @BeforeExecution, which is run before the actual change is executed, this means, for example, that the method annotated with @BeforeExecution will be out of the native transaction linked to the changeLog, however, Mongock will try to revert the changes applied by the method @BeforeExecution by executing the method annotated with @RollbackBeforeExecution
The concept is basically the same, a class that wraps the logic of the migration
Classes annotated with @ChangeUnit must have the following: - One(and only one) one valid constructor annotated with @ChangeUnitConstructor(mandatory if more than one constructor exist after version 6) - One(and only one) method annotated with @Execution(mandatory) - One(and only one) method annotated with @RollbackExecution(mandatory) - At most, one method annotated with @BeforeExecution(optional) - If contains a method annotated with @BeforeExecution, one(and only one) method annotated with @RollbackBeforeExecution(mandatory if @BeforeExecution present)
Please follow one of the recommended approaches depending on your use case: - For existing changeLogs/changeSets created prior version 5: leave them untouched (use with the deprecated annotation)
- For new changeLogs/changeSets created from version 5: Annotated you class migration class with the annotation @ChangeUnit
| Modifier and Type | Required Element and Description |
|---|---|
String |
id
Change unit's id.
|
String |
order
Equivalent to field `order` in ChangeSet annotation and ChangeLog,
as now there is only one "changeSet", annotated with @Execution
|
| Modifier and Type | Optional Element and Description |
|---|---|
String |
author
Equivalent to field `author` in ChangeSet annotation
|
boolean |
failFast
Equivalent to field `failFast` in ChangeSet annotation
|
boolean |
runAlways
Equivalent to field `runAlways` in ChangeSet annotation
|
String |
systemVersion
Equivalent to field `systemVersion` in ChangeSet annotation
|
boolean |
transactional
If true, Mongock will try to run the changeUnit in a native transaction, if possible.
|
public abstract boolean failFast
ChangeSetpublic abstract boolean runAlways
ChangeSetCopyright © 2024. All rights reserved.