DEV Community

Rohith Kunnath
Rohith Kunnath

Posted on

1 1

Test Liquibase migration changes in the local environment using Docker

I am publishing this article because recently found out we had problems in the pre-live environment related to some liquibase migration issue.

Then I was thinking maybe this could be because of not testing properly in our local environment or not knowing how to do testing itself.

Unfortunately, some commands use java-maven, but I am sure there are alternatives for these statements.

Maybe the following could help someone :)

Prerequisites :

  • Docker

Steps to do:

  • Docker-compose file content can be copied from here - https://hub.docker.com/_/postgres
  • docker-compose up - Runs a container with Postgress DB running inside
  • docker ps - Lists the container details
  • Do an export of schema from prelive or test environment.
  • docker exec -it {replace_with_container_id} bash - You can login to the container and import the exported schema.
  • From your local, open changelog.xml and comment out changes other than yours.
  • Change liquibase configuration inside pom.xml to local postgres configuration.
  • Run the command mvn liquibase:update to see your changes being applied.

Tips for postgres newbie:

Once you login to the docker container using STEP-5 mentioned in Steps to do,

  • execute command psql -U postgres - "postgres" is the username used in the docker-compose content.

  • \c {db_name} - connect to a db

  • \dt - show tables in that database

  • \d {table_name} - describe table

Thank you for reading and I am happy if I could help someone.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more