7

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'
);
/
user3006906
  • 71
  • 1
  • 3
  • SQL statements are terminated with a `;` the `/` does not make sense. What you have that `/` at the end? –  Nov 23 '17 at 19:54
  • what if you set your end delimiter as `\n/`? – bilak Nov 24 '17 at 12:21
  • I've tried different rollbackEndDelimiters but none have worked. I only used "/" because I had seen it used in a example. – user3006906 Nov 27 '17 at 15:47
  • @a_horse_with_no_name See SQL example in [docs](https://docs.liquibase.com/concepts/advanced/enddelimiter-sql-attribute.html) – shmuels Jan 05 '21 at 19:53

1 Answers1

4

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.

Yuri
  • 4,254
  • 1
  • 29
  • 46
Bo Guo
  • 101
  • 3
  • Ya maybe I am just misunderstanding what rollbackSplitStatements and rollbackEndDelimiter are used for. I can't find any documentation on their usage. – user3006906 Dec 04 '17 at 17:58