WEBjuju
WEBjuju

Reputation: 6591

Override Liquibase CLI properties on cmd line

We need to interpret/override the database name in the liquibase.properties file.

Here are two things we've tried:

liquibase --url="${referenceUrl}" update
liquibase --database-name=BASELINE update

Neither of those override the database name.


tldr;

The process without Liquibase is as follows:

  1. Developer makes changes to dev database
  2. Developer commits drift they introduced
  3. Infra uses commits to update next hierarchic database

The referenceUrl keeps the baseline (db named "BASELINE"). Then Liquibase records the drift and commits changelogs. But after that the baseline database needs to be updated which should be as easy as switching the database name (since all other properties, url, host, password match between the dbs).

Here are the commands that do work. Note how we needlessly have to have a second properties file just to switch url with referenceUrl.

# generate change log from work developer did on db
liquibase --changeLogFile="logs/v<YYYYMMDDHHII>.xml" generateChangeLog;

# update "baseline" reference database
liquibase --defaults-file=baseline_reference.properties update;

Question is:

How to update reference url without a second properties file?

Upvotes: 0

Views: 25

Answers (2)

WEBjuju
WEBjuju

Reputation: 6591

The fact that Liquibase has referenceUrl for diff operations but no easy way to say "now update that reference database instead" seems like a design oversight.

Something like this SHOULD exist (but doesn't):

liquibase --target=reference update
# or
liquibase --use-reference-url update

It's especially frustrating because: The reference database info is already in the properties file.

We're just wanting to temporarily switch which database gets updated.

This seems like a common need - update your baseline after confirming the changes look good.

For now we're stuck with either:

  • Two properties files
  • Long command line URLs
  • Shell script tricks None of which feel "right"...

Upvotes: 0

Alon Alush
Alon Alush

Reputation: 1089

Liquibase does not allow overriding the reference URL (or its derived properites such as databaseName) via CLI.

Consider changing your liquibase.properties to use a variable for the reference URL, for example:

referenceUrl=${REFERENCE_URL}

And when running liquibase, supply the environment variable or JVM system property:

REFERENCE_URL=jdbc:yourReferenceDb liquibase update

or

liquibase -DREFERENCE_URL=jdbc:yourReferenceDb update

Upvotes: 0

Related Questions