liquibase environment scripts

1.8k views Asked by At

I have just discovered Liquibase and I'm currently working on trying to automate my Oracle database releases.

I am trying to find out more about how I can use perform token replacement for my SQL scripts that may vary depending on my environment I run Liquibase on.

Specifically, does Liquibase support the concept of environment-based SQL scripts? I.e I may have certain custom SQL scripts which may differ slightly for Test, Regression and Live. So that when executing my Liquibase release to Regression, only those Regression specific changesets are executed, perhaps with a Regression parameter.

Thanks in advance!

1

There are 1 answers

4
SteveDonie On

Yes, Liquibase uses 'labels' and 'contexts' to control which changesets are applied in different environments. This blog post describes them in more detail:

http://blog.liquibase.org/2014/11/contexts-vs-labels.html

Liquibase also supports properties in changelogs that can be set in various ways - this page of the docs shows the details:

http://www.liquibase.org/documentation/changelog_parameters.html

Here is a snippet of that documentation:

Liquibase allows dynamic substitution of parameters in a changelog. The parameters to replace are described using the ${} syntax.

Configuring parameter values

Parameter values are looked up in the following order:

  • Passed as a parameter to your Liquibase runner (see Ant, command_line, etc. documentation for how to pass them)
  • As a JVM system property
  • In the parameters block (<property> Tag) of the DatabaseChangeLog file itself.