Reputation: 2436
I just started using Liquibase to manage my schema and I'm using the Maven commands to execute Liquibase. I've been successful in updating the schema, however I'm experiencing an issue while testing the rollback feature.
SQL Format Changelog
--changeset me:create-myschema
CREATE SCHEMA myschema;
--changeset me:create-table1
CREATE TABLE myschema.table1(
id bigint,
description varchar(100)
);
--rollback DROP TABLE myschema.table1;
--changeset me:create-table2
CREATE TABLE myschema.table2(
id bigint,
code varchar(10)
);
--rollback DROP TABLE myschema.table2;
-- changeset me:tag-1.0
UPDATE databasechangelog SET tag='1.0' WHERE dateexecuted = (SELECT max(dateexecuted) FROM databasechangelog);
Maven Rollback Command
mvn liquibase:rollback -Dliquibase.rollbackTag=1.0
Results
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.6.1:rollback (default-cli) on project myproject: Error setting up or running Liquibase: liquibase.exception.RollbackImpossibleException: No inverse to liquibase.change.core.RawSQLChange created -> [Help 1]
Upvotes: 0
Views: 7106
Reputation: 65
You can also use mvn liquibase:rollback "-Dliquibase.rollbackCount=1" to rollback latest update.
https://docs.liquibase.com/tools-integrations/maven/commands/maven-rollback.html
And
You can just go to your database and find "databasechangelog" table and delete manualy that change row you made with your liquibase script and also delete all changes you made by running liquibase script.
Upvotes: 1
Reputation: 9016
Liquibase is saying that you don't have a rollback tag defined for the changeset me:tag-1.0
. Since Liquibase doesn't know that that changeset is a 'tag database' changeset, you would have to tell it that there is no rollback by specifying an empty rollback for that changeset.
-- changeset me:tag-1.0
UPDATE databasechangelog SET tag='1.0' WHERE dateexecuted = (SELECT max(dateexecuted) FROM databasechangelog);
-- rollback
-- changeset me:next-change
Upvotes: 1