Reputation: 11
Liquibase is analogous EntityFramework(EF) in Java world.
And liquibase:diff
= Add-Migration
in EF
.
But problem is that liquibase:diff
only generates the changelog
but with out the rollback.
Is it possible generate the diff along with rollback.
I tried creating rollback script with liquibase:rollback
. but it is not able to generate rollback script in all cases for example when I dropped a column with a change set and later wanted to rollback.
Error setting up or running
Liquibase: liquibase.exception.RollbackImpossibleException: No inverse to liquibase.change.core.DropColumnChange created -> [Help 1]
Upvotes: 1
Views: 663
Reputation: 634
Nathan Voxland, the author of the Liquibase, pretty much answered your question here: http://www.liquibase.org/2007/06/the-problem-with-database-diffs.html
In short, some of the changes generated by diff
are themselves questionable until reviewed by a qualified developer, who understands the purpose of the changes.
Rollback is even more complicated and is, therefore, left to the developer in most cases.
As Jens mentioned in the comment to your question, some changes you generate could be rolled back automatically (relatively safely). Others, however, are not going to work that nicely.
If there are changesets with no automatic way of rolling back, you need to write your own rollbacks in the changeset. For example, if you drop a column -- there is simply not enough info in the changeset itself to recreate the column and all data. The reversal script might look like "ALTER TABLE Z ; UPDATE TABLE Z SET A=; "
While luquibase:diff
probably could create "some more" rollback given the knowledge of both source and target systems (e.g. fetch the column datatype from the "old version" while writing a "DROP COLUMN" changeset and inject a custom "rollback" section), it would ultimately create a sense of false security, getting it to the undesired extents.
Upvotes: 1