开发者

using liquibase on existing schema

开发者 https://www.devze.com 2023-03-24 08:02 出处:网络
I\'ve read about how you can generate changelog.xml from an existing schema. That\'s fine, but I have existing systems that I don\'t want to touch, except to bring in new changes. I also have complete

I've read about how you can generate changelog.xml from an existing schema. That's fine, but I have existing systems that I don't want to touch, except to bring in new changes. I also have completely new systems which require all changes be applied.

So, I want to get liquibase to only perform migrations from changeset X when running on an existing system. I.e. that system's DB is at revision开发者_如何学编程 X-1 (but no liquibase sys tables), and I don't want any preceeding migrations applied.

Many thanks, Pat


I would recommend a slightly different approach, as commented in this Liquibase forum thread

  1. generate a changelog from your existing schema. The liquibase CLI can do that for you. I usually take the resulting XML and smooth it out a bit (group related changes into single changelogs, do vendor-specific cleanups and so on), but Liquibase does most of the legwork.

  2. run that changelog against the existing database (changelogSync command), but only marking it as applied (without actually modifying the schema).

  3. use liquibase for applying new changes from that point on.


I think the easiest would be to execute the initial setup on an empty database at first and export the entry(ies) liquibase does insert into the DATABASECHANGELOG table. Then I'd export these entries and insert them manually into one of the target databases into their DATABASECHANGELOG table, so liquibase does not execute the "change" there again.

Of course I'd test all that with test dumps on a test machine... :)

0

精彩评论

暂无评论...
验证码 换一张
取 消