You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Steps to test liquibase changeset

1. Run a new postgres instance container on your local machine

docker run --name postgres -p 5432:5432 -d -e POSTGRES_DB=cpsdb -e POSTGRES_USER=cps -e POSTGRES_PASSWORD=cps postgres:13.2-alpine

2. Checkout honolulu branch and cd to "cps-ri" 3. Run "status" liquibase script to observe that your database is not up to date and see the list of all changes set that need to be applied for honolulu

mvn clean compile org.liquibase:liquibase-maven-plugin:4.3.1:status -Dliquibase.url=jdbc:postgresql://localhost:5432/cpsdb -Dliquibase.username=cps -Dliquibase.password=cps -Dliquibase.changeLogFile=changelog/changelog-master.yaml

4. Run "update" liquibase script to apply all pending changes set and bring your database to honolulu version

mvn clean compile org.liquibase:liquibase-maven-plugin:4.3.1:update -Dliquibase.url=jdbc:postgresql://localhost:5432/cpsdb -Dliquibase.username=cps -Dliquibase.password=cps -Dliquibase.changeLogFile=changelog/changelog-master.yaml

5. Run "status" liquibase script to validate that your db is now up to date for honolulu (Run step 3 command) 6. Check out master branch (or the branch having your liquibase fix) and cd to "cps-ri" 7. Run "status" liquibase script to see the list of all change sets that need to be applied for istambul (if any) (Run step 3 command)

  • If the script is failing because of a checksum validation, it indicates that a specific change set already applied has been modified resulting in the script being now inconsistent with the database.
  • If the script completes successfully, it lists pending change sets to be applied (if any).

8. Run "update" liquibase script to apply all pending changes set and bring your database to istanbul version (Run step 4 command) 9. Run "status" liquibase script to validate that your db is now up to date for istambul (Run step 3 command)

9. In case the latest updates needs to be rolled back, the below options could be used:

  • liquibase.rollbackCount - reverts a specified number of changesets sequentially, starting with the most recent changes and working backward until the value specified is reached :
    • mvn clean compile org.liquibase:liquibase-maven-plugin:3.8.7:rollback -Dliquibase.url=jdbc:postgresql://localhost:5432/cpsdb -Dliquibase.username=cps -Dliquibase.password=cps -Dliquibase.changeLogFile=changelog/changelog-master.yaml -Dliquibase.rollbackCount=x


  • liquibase.rollbackTag - reverts all changes that were made to the database after the specified tag:
    • mvn clean compile org.liquibase:liquibase-maven-plugin:3.8.7:rollback -Dliquibase.url=jdbc:postgresql://localhost:5432/cpsdb -Dliquibase.username=cps -Dliquibase.password=cps -Dliquibase.changeLogFile=changelog/changelog-master.yaml -Dliquibase.rollbackTag=<liquibase_tag_for_changesets_to_be_rolled_back>
  • liquibase.rollbackDate - reverts all changes made to your database from today's date to the date and time you specify.
    • mvn clean compile org.liquibase:liquibase-maven-plugin:3.8.7:rollback -Dliquibase.url=jdbc:postgresql://localhost:5432/cpsdb -Dliquibase.username=cps -Dliquibase.password=cps -Dliquibase.changeLogFile=changelog/changelog-master.yaml -Dliquibase.rollbackDate=2020-11-26


Note about rollback

See:

* https://docs.liquibase.com/concepts/bestpractices.html in "Always think about rollback" section
* https://docs.liquibase.com/workflows/liquibase-community/using-rollback.html

  • No labels