Skip to content

Instantly share code, notes, and snippets.

@alismx
Last active April 7, 2023 20:33
Show Gist options
  • Save alismx/ac68b4781c7c500bf5c2aa9bd4aaff7c to your computer and use it in GitHub Desktop.
Save alismx/ac68b4781c7c500bf5c2aa9bd4aaff7c to your computer and use it in GitHub Desktop.
Script to handle some liquibase commands related to checksums and rollbacks
#!/bin/bash
# Pick and set one of these environmet variables
tag="$LIQUIBASE_ROLLBACK_TAG"
count="$LIQUIBASE_ROLLBACK_COUNT"
clear="$LIQUIBASE_CLEAR_CHECKSUMS"
if [ "${clear}" = "true" ]; then
echo "Clearing checksums..."
gradle liquibaseClearCheckSums
else
# Only run validations if not clearing checksums
echo "Running validations..."
gradle liquibaseValidate
if [ -n "${tag}" ]; then
echo "Rolling back to tag: ${tag}"
gradle liquibaseRollback -PliquibaseCommandValue="${tag}"
elif [ -n "${count}" ]; then
echo "Rolling back by count: ${count}"
gradle liquibaseRollbackCount -PliquibaseCommandValue="${count}"
else
echo "No rollback tag or count provided! Taking no action."
exit 0
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment