1
votes

I am brand new to Liquibase...

Today I wrote a Liquibase changeset using --liquibase formatted sql.

I created two tables where the second had a foreign key dependency on the first.

My rollback strategy was (mistakenly) drop table1; drop table2. When I ran the update and tested the rollback it failed because of the foreign key constraint. However, when I corrected my mistake and attempted to rerun it, it failed because the checksum didn't match.

I know that the obvious answer is to make more atomic changesets, however...

Does Liquibase support a way to test this sort of thing without actually running it so I can avoid the problem with the checksum on the edited rollback?

Failing that: is there a workaround for the checksum problem that will let me edit my files after running the update? (ctrl+z?)

2

2 Answers

2
votes

The short answer to your question is, no Liquibase doesn't have such a thing.

Liquibase is a great toolkit, but it doesn't have a lot of bells and whistles, and it doesn't have much of an 'opinion' on how it should be used, or what your workflow should be. In your case, I would suggest that one way to deal with the problem is to just drop the database and then re-create it from the changelog. If you have already deployed the changelog in multiple places, that might not be possible, and if you weren't prepared to do that, that could be a problem.

There is an option to specify a validChecksums attribute on a changeset, so you could use that, but in general if you are using that you are making your changelog more complicated.

If you wanted to look at something that is more full-featured and that has the ability to forecast changes before they are deployed, please check out my company's product, Datical DB. It uses liquibase at its core, but adds a whole lot more (and is priced accordingly).

0
votes

Liquibase provides updateTestingRollback command that basically updates the database, then tests its rollback and if successful, applies the changes again.

Your problem with invalid checksums may be solved with clearCheckSums command. It removes current checksums from database and on next update change sets that have already been deployed will have their checksums recomputed, and change sets that have not been deployed will be deployed.

For more details check Liquibase commands.