What are the most effective Liquibase rollback strategies?


Currently, I am working on a project that involves managing database migrations in various settings, such as development, testing, staging, and production, with Liquibase.

I have some experience with Liquibase, but I want to be sure that my team is following best practices to avoid any issues during deployment.

So I want to know: What is the best way to organize and maintain change logs in several settings?
How do you handle reductions if a migration fails in one of the settings?

I would really appreciate your experiences.
Thanks in advance for your help!

These recommendations are my personal experience from being Liquibase SME (and Oracle/Postgres DBA) at my company, advising 100s of developers on how to use Liquibase.

  1. Develop a single set of changelogs, do not use different changelogs for different environments. I think this is the single most important factor.

  2. Use a combination of properties, contexts, and preconditions to handle any environmental differences that are required in your changelogs.

Use contexts if you have an entire changeset that is unique to a single environment. This allows you to have an environment-specific changeset.

Use preconditions if your environments already have differences you need to handle. This allows you to handle objects that might exist in some, but not all, of your environments.

Use properties (variables) if you need to have certain values differ between your environments. Maybe a user or role-name differs between your environments, properties are perfect for this.