1
votes

I use sqlfile mode. in a sql file I wrote severals changeset :

--liquibase formatted sql

--changeset chs:31 
create table tab_tst3(
    id int primary key,
    name varchar(255)
);
--rollback drop table tab_tst3;

--changeset chs:32 
insert into tab_tst3 (id, name) values (1, 'tab 1');
insert into tab_tst3 (id, name) values (2, 'tab 2');

--changeset chs:33
create sequence tab_seq3;
--rollback drop sequence tab_seq3;

when i execute that file like :

liquibase --driver=oracle.jdbc.OracleDriver --url=jdbc:oracle:thin:@xxxxxx--username=xxx--
password=xxx --changeLogFile=myfile.sql

Starting Liquibase at jeu., 08 ao¹t 2019 15:48:14 CEST (version 3.7.0 built at 2019-07-16 02:26:39) Successfully tagged 'xxxx'

And when I do

liquibase --driver=oracle.jdbc.OracleDriver --url=jdbc:oracle:thin:@xxxxxx--username=xxx--
password=xxx --tag=myTAG

Only the last ligne is tagged (chs:33)

How to tag all the 3 lines with the same tag ?

thanks

1

1 Answers

1
votes

What the tag command does is mark a particular set of changes that have been deployed already as "this set of changes is in a good state that I might want to get back to". So the idea is that you ran liquibase update and the three changesets in the changelog at that time get deployed to the database. You do some testing, and you decide that everything is good, so you run liquibase tag to mark that spot. You continue development, and add some new changesets, and use liquibase update to deploy those to the database. During your testing, you discover a problem, so you want to go back to the last known good state, so you use the liquibase rollback command with the tag you applied and it rolls back the newer changes that were problematic, getting you back to a known good state.