Using liquibase on the existing database

yottabrain picture yottabrain · May 9, 2013 · Viewed 7.2k times · Source

We have a existing database in production. We have decided to use liquibase for all further updates and create any new database (like development or integration).

We have created liquibase scripts based on the existing production schema (to create any new database like development, integration, etc). On top of that script we have also added two more updates. Going forward all further updates to production DB will be done by liquibase.

If we execute the liquibase on production, it will try do all the complete changes even those which are already exist, which should not happen as production already has everything except the two new updates. Now we want to use the liquibase to update those two changes alone to productions.

How we can do this?

Answer

a_horse_with_no_name picture a_horse_with_no_name · May 9, 2013

The process to put a existing database under liquibase control is the following:

  1. Create the initial changelog (that's what you did)
  2. Run liquibase using the command changelogSync. This will create the Liquibase tables and mark all change sets as being applied (this is what you missed)
  3. Add your change sets
  4. Run liquibase using the command update to apply the change sets.