Reputation:
I am adding Liquibase database migration to our currently product deployment using RPM, and am looking for some advice/tips on how to achieve my desired goal.
Preferably the RPM would be able to be installed in brand new and shiny developer environments, as well as existing integration/production systems.
I've used generateChangeLog to create an xml changelog of the current (pre-liquibase) db schema, and I've got our master changelog created and ready to go forward with new changesets as needed.
However, I am trying to determine the best way to conditionally have the generated initial schema be executed one-time if necessary (ie: on a fresh new db). Contexts don't seem super ideal, just due to the fact that I'd need to have some other external way to communicate to the RPM what contexts it should run as, and that seems error-prone.
I'd also like the legacy generated change log to appear as having been run in the DATABASECHANGELOG table, to have the project appear as if it has always been liquibase managed.
Appreciate any help or guidance,
Thanks in advance
Upvotes: 0
Views: 591
Reputation: 1932
You can put all of your initial lb changes into one single changeset and put a precondition tableExists
into that changeset, checking for any table from your model. If that table doesn't exist -> you have an empty data base so your big changeset will create all the objects. If the table exists -> you are running on an existing database, so it should be skipped (use onFail="MARK_RAN"
with precondition).
Upvotes: 0