In 3.5.2 rollbackSplitStatements and rollbackEndDelimiter were introduced to allow us to write our rollback statements in multiple lines and not have to tag every line with "--rollback" or at least I am assuming that from the PR (https://github.com/liquibase/liquibase/pull/334).
But I have not see any documentation on how to use it.
As an example:
--changeset auth:1.1 rollbackSplitStatements:false rollbackEndDelimiter:/
DELETE FROM my_table WHERE id = 3;
--rollback
insert into my_table values (
3,
'firstname',
'lastname'
);
/
This throws an error during migrate:
Unexpected error running Liquibase: ERROR: syntax error at or near "/"
Alternatively this does not throw an error but does execute the statement under "--rollback" during migrate:
--changeset auth:1.1
DELETE FROM my_table WHERE id = 3;
--rollback rollbackSplitStatements:false rollbackEndDelimiter:/
insert into my_table values (
3,
'firstname',
'lastname'
);
/
Liquibase provides commands to allow you to undo changes you have made to your database, either automatically or with a custom rollback command. The intention of a rollback script is to return the database to a previous specified point in time. Note: Rollback support is available in command line, Ant, and Maven.
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.
Liquibase (LB) is an open source tool written in Java. It makes defining database changes easy, in a format that's familiar and comfortable to each user. Then, it automatically generates database-specific SQL for you. Database changes (every change is called changeset) are managed in files called changelogs.
I wish multi-line rollback worked the way you presented. I am using 3.5.3, still had to put --rollback
in front of each line as
--changeset auth:1.1 rollbackSplitStatements:false
DELETE FROM my_table WHERE id = 3;
--rollback insert into my_table values (
--rollback 3,
--rollback 'firstname',
--rollback 'lastname'
--rollback);
In fact, the rollbackSplitStatements
setting does not seem to make any difference in my tests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With