Liquibase sqlFile in changeset not executed

Hi,

I am trying to run a changeset with sqlFile tag but it isn’t getting executed. The liquibase update command says successfully executed but the databasechangelog also doesn’t contain any reference of the changeset.

Below is my master changeset.xml

<?xml version="1.0" encoding="UTF-8"?>  
  <databaseChangeLog  
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
    http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd
    http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

  <include file="changesets/release1/changelog.xml" labels="release1" relativeToChangelogFile="true"/>
  <include file="changesets/release2/changelog.xml" labels="release2" relativeToChangelogFile="true"/>
</databaseChangeLog>

Below is my release1/changelog.xml

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xmlns:pro="http://www.liquibase.org/xml/ns/pro"
                    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.0.xsd
	                http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.0.xsd">

    <!-- Please assign labels for all changesets as this will be used in DB Change Log table. -->
    <property name="label" value="release1" />


    <changeSet labels="${label}" author="anuj.batra" id="sample.1.changeset" runOnChange="true" context="${label}">
        <comment>This section makes sure to enter values of the reason why change is made.</comment>
        <sqlFile dbms="h2, oracle, mysql" encoding="UTF-8" path="rollforward/sample.changeset.sql" relativeToChangelogFile="true" />
        <rollback>
            <sqlFile dbms="h2, oracle, mysql" path="rollback/sample.changeset.rollback.sql" relativeToChangelogFile="true"/>
        </rollback>
    </changeSet>

</databaseChangeLog>

Below is my roolforward.sql file

CREATE TABLE People (
    PersonID int,
    LastName varchar(255),
    FirstName varchar(255),
    Address varchar(150),
    City varchar(255)
);
INSERT INTO People (PersonID, LastName, FirstName, Address, City)
VALUES (1, 'Doe', 'John', '1 Woolworths Way', 'Bella Vista');

INSERT INTO People (PersonID, LastName, FirstName, Address, City)
VALUES (2, 'Doe 1', 'John', '1 Woolworths Way', 'Bella Vista');

INSERT INTO People (PersonID, LastName, FirstName, Address, City)
VALUES (3, 'Doe 2', 'John', '1 Woolworths Way', 'Bella Vista');

INSERT INTO People (PersonID, LastName, FirstName, Address, City)
VALUES (4, 'Doe 3', 'John', '1 Woolworths Way', 'Bella Vista');

I’ve tried deleting the database changelog and lock tables to import again but no luck. Both release1 and release2 changesets are not getting executed

I am using mysql database and below is my properties file

url=jdbc:mysql://localhost:3306/test?useLegacyDatetimeCode=false&serverTimezone=Australia/Sydney&autoCommit=true&character_set_server=utf8mb4
driver=com.mysql.cj.jdbc.Driver
username=test
password=test

Below is my databasechangelog
|ID|AUTHOR|FILENAME|DATEEXECUTED|ORDEREXECUTED|EXECTYPE|MD5SUM|DESCRIPTION|COMMENTS|TAG|LIQUIBASE|CONTEXTS|LABELS|DEPLOYMENT_ID|
|—|---|—|---|—|---|—|---|—|---|—|---|—|---|
|1612221150384|liquibase|liquibase-internal|2021-02-02 10:12:30|1|EXECUTED|8:d41d8cd98f00b204e9800998ecf8427e|empty||release2|4.2.1|NULL|NULL|2221150315|

Hello @abatra!

From what you’ve provided, I don’t see anything obvious that might be causing the sample.changeset.sql script to be skipped. What might be helpful is a description of the directory structure of your changelog files. When working with includes things can get a little tricky at first.

It would also be great to see a DEBUG log from the update.

Pete

1 Like

Hi @abatra ,

I am seeing something and I wonder if this might be the root cause of the issue (mismatch between the file name and the value set in the path attribute?):

The sqlFile path is set to: =“rollforward/sample.changeset.sql”
The presented sql file is named: roolforward.sql

If this doesn’t fix the issue, could you also add the folder structure (starting from root, where the main changelog reside)?

Also, what RDBMS are you using? If you are using something different than h2, oracle, mysql (i.e if using SQL Server or PostgreSQL) then this might be other cause. (edit update: based on the driver, the RDBMS is MySQL).

Hope this helps,
Eduard

2 Likes