33

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?

yottabrain
  • 2,387
  • 5
  • 23
  • 37

1 Answers1

49

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.
  • This is the answer I was looking for. Thanks :) – Pavan Jadda Feb 08 '19 at 03:57
  • assume my production schema is "s1". now i have created my changes in another schema called "s2". i have done section 1 and 2 that you said. next i have created a diff between s1 and s2 and append all of diff file content to end of changeLong that created in section 1.then i run update command but process fails :(((. what is wrong? – Mahdiyar Zerehpoush Jul 27 '19 at 17:14
  • Is this how to create a initial changelog? https://stackoverflow.com/questions/12449824/ – surfmuggle May 15 '20 at 12:30
  • @surfmuggle: https://docs.liquibase.com/workflows/liquibase-community/existing-project.html –  May 15 '20 at 12:31
  • Thanks! Google still points to this [empty url](https://www.liquibase.org/documentation/existing_project.html) – surfmuggle May 15 '20 at 12:39