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
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.
run that changelog against the existing database (
changelogSync
command), but only marking it as applied (without actually modifying the schema).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... :)
精彩评论