I have an issue when using liquibase:updateSQL goal in maven.
I have a fresh database and this is the first time liquibase accesses the database.
When using mvn install liquibase creates the two tables DATABASECHANGELOG and DATABASECHANGELOGLOCK into the database,
and it also adds the creation of these tables to the migration script that is generated alongwith other changes that need to be applied to the database.
– Create Database Lock Table
CREATE TABLE my_db.DATABASECHANGELOGLOCK (ID INT NOT NULL, LOCKED TINYINT(1) NOT NULL, LOCKGRANTED DATETIME, LOCKEDBY VARCHAR(255), CONSTRAINT PK_DATABASECHANGELOGLOCK PRIMARY KEY (ID));
INSERT INTO my_db.DATABASECHANGELOGLOCK (ID, LOCKED) VALUES (1, 0);
SELECT LOCKED FROM my_db.DATABASECHANGELOGLOCK WHERE ID=1;
– Lock Database
UPDATE my_db.DATABASECHANGELOGLOCK SET LOCKEDBY = ‘192.168.1.110’, LOCKGRANTED = ‘2010-10-01 11:50:14.140’, LOCKED = 1 WHERE ID = 1;
– Create Database Change Log Table
CREATE TABLE my_db.DATABASECHANGELOG (ID VARCHAR(63) NOT NULL, AUTHOR VARCHAR(63) NOT NULL, FILENAME VARCHAR(200) NOT NULL, DATEEXECUTED DATETIME NOT NULL, MD5SUM VARCHAR(32), DESCRIPTION VARCHAR(255), COMMENTS VARCHAR(255), TAG VARCHAR(255), LIQUIBASE VARCHAR(10), CONSTRAINT PK_DATABASECHANGELOG PRIMARY KEY (ID, AUTHOR, FILENAME));
Obviously either 1 of the two should happen.
Thus when I use the migration script IT WILL throw an error as the two tables DATABASECHANGELOG and DATABASECHANGELOGLOCK already exist.
I know I can manually remove the above sql from the migration.sql file that has been generated. But I don’t want to do that inorder to keep the build automated.
Maybe I have missed something. Any help or solution would be greatly appreciated.