-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CustomChangeChecksum interface (#5649)
CustomChangeChecksum interface Adds a new optional interface: CustomChangeChecksum, that you can implement on any CustomChange. Will let you configure how the checksum for your specific change will be calculated, if you're not happy with the default. Closes #5478
- Loading branch information
1 parent
6f50035
commit 14288cf
Showing
4 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
liquibase-standard/src/main/java/liquibase/change/custom/CustomChangeChecksum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package liquibase.change.custom; | ||
|
||
import liquibase.change.AbstractChange; | ||
import liquibase.change.CheckSum; | ||
|
||
/** | ||
* Interface to implement that allows a custom change to generate its own checksum. | ||
* | ||
* @see liquibase.change.custom.CustomChange | ||
* @see AbstractChange#generateCheckSum() | ||
*/ | ||
public interface CustomChangeChecksum { | ||
|
||
/** | ||
* Generates a checksum for the current state of the change. | ||
* | ||
* @return the generated checksum | ||
*/ | ||
CheckSum generateChecksum(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...se-standard/src/test/java/liquibase/change/custom/ExampleCustomSqlChangeWithChecksum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package liquibase.change.custom; | ||
|
||
import liquibase.change.CheckSum; | ||
|
||
public class ExampleCustomSqlChangeWithChecksum extends ExampleCustomSqlChange implements CustomChangeChecksum { | ||
|
||
// Some synthetic field to be used in our checksum calculation | ||
private final Integer version = 5; | ||
|
||
/** | ||
* Generate a checksum based on the classname and the version number within. | ||
* Does not care about any parameters set | ||
* @return the calculated checksum | ||
*/ | ||
@Override | ||
public CheckSum generateChecksum() { | ||
return CheckSum.compute(getClass().getName() + ":" + version); | ||
} | ||
} |