Handling of upgrade via liquibase

We are using liquibase for postgres.

Our CI / CD process is like below.

  1. We have a single sql file for managing all DB changesets.
  2. We have multiple instances of a same microservice (AWS ECS) running talking to the same database.
  3. During release, in our CI we first execute the SQL changesets via liquibase and then proceed with the upgrade of microservice code.
  4. Services get upgraded one by one.

In the above approach we are observing a problem where let’s say a some column is dropped in a table and the application code is changed accordingly. But the code on each service instances gets upgraded one by one, so the service where the new code has not reached it will start throwing error if they try to access the dropped column.

Can someone let me know how people are handling these type of cases?

However, once all the service instances are upgraded with the new code, it starts working fine. I am specifically asking about the failure during upgade process when the new code has not reached every instance.

Liquibase Docker Version - 4.5.0

One option. If you can’t shut them all down, do the db update, and then restart, then an option would be to update all the microservice instances with new version of code BEFORE dropping the column from the table. That new version might be as simple as just not selecting / updating that column, or if the column is a required column, then add some conditional code based on presence of that column. Then run the db update…

1 Like

Do liquibase sql changelog format provide any support for writing conditional code in the sql file?


You can add a precondition to a changeset: