We're using Liquibase to handle our DB Schema changes. As we already have quite a large set of ChangeLogs distributed over multiple files, arranged in a complex folder structure, there sometimes rises the need or the desire to make some refactorings that would influence the meta information in the DatabaseChangeLog table.
What is the recommendation for such refactorings? Can I use Liquibase itself to update the DatabaseChangeLog entries or will I run into caching issues?
A simple example to make my case clearer:
- I have created a new changeLog file test/changeLog.xml with the default logicalFilePath containing a few changeSets
- As the file grows bigger, I'd like to split it up into multiple files, move them around in some sub folders and explicitly set the logicalFilePath attribute to 'myChanges' to group them
- As these changes have already run, I would have to update the DATABASECHANGELOG.FILENAME field, otherwise Liquibase will think that i have introduced new change sets
- I would need to run an UPDATE DATABASECHANGELOG set FILENAME='myChanges' WHERE FILENAME='test/changelog.xml'
- Of course, I want to do this in an automated way. What's the best way to do it? Can I use Liquibase itself? Or do I need to update DATABASECHANGELOG in another way (JDBC or whatever) BEFORE I run Liquibase with the new structure?
Thanks for a feedback!
Some follow up:
Sometimes it's just unfortunate that change sets cannot be adapted. Consider the following case:
- We created a new table with VARCHAR2(255 byte)
- Everything was fine, table was deployed and populated with data
- I introduced an embedded H2 database for testing that wouldn't understand "255 byte", but only 255. For the original database, changing it to VARCHAR(255) wouldn't make a difference, but it would change the checksum of the changeset and lead to a Liquibase error.
- Dropping and recreating the table isn't an option either as the table is already populated with data
- Using plain Liquibase, I would end up with a solution like creating a new table, moving over my data, deleting the old table and renaming the new one...