Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging LiquiBase changesets

I'm developing a system with database version control in LiquiBase. The system is still in pre-alpha development and there are a lot of changes that were reverted or supplemented by other changes (tables removed, columns added and removed).

The current change set reflects the whole development history with many failed experiments, and this whole is rollouted when initializing the database.

Because there is NO release version, I can start from scratch and pull actual DB state in single XML changeset.

Is there a way to tell LiquiBase to merge all change sets into one file, or the only way to do that is per hand?

like image 343
9ilsdx 9rvj 0lo Avatar asked Dec 12 '17 10:12

9ilsdx 9rvj 0lo


People also ask

What is the purpose of adding changesets to your changelog?

A change is contained in a changeset and changesets are added to the changelog in the order they need to be deployed. Simply put – a changelog contains an ordered list of changesets, and a changeset contains a change.

What are Liquibase changesets?

The changeset tag is a unit of change that Liquibase executes on a database and which is used to group database Liquibase Change Types together. A list of changes created by multiple changesets are tracked in a changelog.


2 Answers

Just use your existing database to generate change log that will be used from now on. For this you can use generateChangeLog command from command line, it will generate the changelog file with all the changeSets that represent your current state of the database. You can use this file in your project as initial db creation file, to be used on an empty database. Here's a link to docs.

like image 146
veljkost Avatar answered Sep 18 '22 09:09

veljkost


There is a page in the Liquibase docs which discusses this scenario in detail: http://www.liquibase.org/documentation/trimming_changelogs.html

To summarise, they recommend that you don't bother since consolidating your changelogs is both risky and low-reward.

If you do want to push ahead with this, then restarting the changelog using generateChangeLog, as suggested by @veljkost, is probably the easiest way. This is documented at http://www.liquibase.org/documentation/existing_project.html

like image 41
Rich Avatar answered Sep 20 '22 09:09

Rich