Rodriguez
Rodriguez

Reputation: 165

Cannot make liquibase execute more than 1 script in one file

I have a spring-boot application and sqlite db. If I write two scripts in one file, only first script make change to db. The table creates but no data inserts, though in log I see that both scripts were executed. And if I write each script to separate file, then it is OK, table creates and data inserts. How to make it execute more then one script in one single file?

CREATE TABLE IF NOT EXISTS acl_class
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
class    character varying UNIQUE NOT NULL
);

INSERT INTO acl_class
(class)
VALUES
('models.User');

The same problem is with mysql db, but here my app falls with runtime error "Caused by: liquibase.exception.DatabaseException: You have an error in your SQL syntax;" But syntax is ok, and separately tables are creating without any problem:

CREATE TABLE IF NOT EXISTS acl_class
(
id INT AUTO_INCREMENT PRIMARY KEY,
class VARCHAR(255) UNIQUE NOT NULL
);

CREATE TABLE IF NOT EXISTS acl_sid
(
id INT AUTO_INCREMENT PRIMARY KEY,
principal    boolean  NOT NULL,
sid VARCHAR(255) UNIQUE NOT NULL
);

Upvotes: 0

Views: 1079

Answers (1)

Rodriguez
Rodriguez

Reputation: 165

Thanks to SteveDonie the problem was solved easily: I just added to the begining of my file with multiply scripts this two lines:
--liquibase formatted sql
--changeset myname:create-multiple-tables splitStatements:true endDelimiter:;
and and it worked!

Upvotes: 1

Related Questions