0

I could not figured out why non of the change-set is getting executed and reflected in DB.

I have referred this link as well,it has same issue unfortunately there is not answer on this post .

In summary no changesets has been executed and my DB has no Tables (except DATABASCHANGELOG) in it.

enter image description here

Please refer below code.

Class "DataVersioningController.java" has main method and it calls the "liquiebaseRun()" method.

public static void main(String args[]) throws LiquibaseException, SQLException {
       new DataVersioningController().liquiebaseRun();

    }

    public void  liquiebaseRun() throws SQLException, LiquibaseException {

       JdbcConnection jdbcConnection = new JdbcConnection(DataVersioningController.getConnection());
       DatabaseChangeLog dbChangeLog = new DatabaseChangeLog("D:\\ChangeSet.xml");
       Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(jdbcConnection);

       ClassLoaderResourceAccessor classLoaderAccessor = new ClassLoaderResourceAccessor();

       CommandLineResourceAccessor clAccessor = new CommandLineResourceAccessor(getClass().getClassLoader());

        CompositeResourceAccessor ref = new CompositeResourceAccessor(new ResourceAccessor[] { clAccessor, classLoaderAccessor });
       database.setDefaultSchemaName("test");
       database.setLiquibaseSchemaName("test");
       Liquibase liquibase = new Liquibase(dbChangeLog, ref, database);
       liquibase.update(new Contexts("test"), new LabelExpression());

       System.out.println("Completed ");
  }

ChangeSet.xml

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

    <changeSet author="admin" id="1" context="test">
        <createTable tableName="person">
            <column autoIncrement="true" name="id" type="INT">
                <constraints primaryKey="true"/>
            </column>
            <column name="name" type="VARCHAR(255)">
                <constraints nullable="false"/>
            </column>
            <column name="address" type="VARCHAR(255)"/>
        </createTable>

    </changeSet>
</databaseChangeLog>
Gautam
  • 3,707
  • 5
  • 36
  • 57

1 Answers1

0

You don't need to call liquibase manualy. If you are using SpringBoot and Maven then add that dependency:

<!-- https://mvnrepository.com/artifact/org.liquibase/liquibase-core -->
        <dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-core</artifactId>
            <version>3.6.2</version>
        </dependency>

and that property to your application.properties:

spring.liquibase.change-log=//path to your changeset