I have the following changelog -
--liquibase formatted sql
--changeset erfan:1
CREATE TABLE IF NOT EXISTS product (
id BIGINT NOT NULL,
name VARCHAR(40) NOT NULL,
quantity INT,
CONSTRAINT pk_product PRIMARY KEY (id)
);
CREATE SEQUENCE product_seq INCREMENT BY 1;
--rollback DROP TABLE product;
--rollback DROP SEQUENCE product_seq;
--changeset erfan:2
ALTER TABLE IF EXISTS product
ADD COLUMN created TIMESTAMP,
ADD COLUMN updated TIMESTAMP,
ADD COLUMN version INT;
--rollback none
While performing rollback with gradle ./gradlew rollbackCount -PliquibaseCommandValue=1
causes the following error
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near “empty”
--rollback empty
also gives the same error.
Changing the rollback statement to --rollback SELECT 'N\A'
according to this discussion, the error resolves but it deletes the corresponding update
entry from the databasechangelog
table while keeping the product
table same.
For this, when I re-run ./gradlew update
command, it fails because the columns already exist. Since the record of changeset erfan:2
is removed from the databasechangelog table, the update command tries to execute the changeset erfan:2
again.
I am using
- liquibase 4.18.0
- Spring boot 2.7.7
- gradle 7.6
- liquibase gradle plugin 2.0.4