spring-bootliquibaseamazon-auroraliquibase-sql

Springboot Liquibase AWS Aurora DB Application Startup issue


I have an existing spring boot application and i need to connect to Aurora DB using liquibase and create tables . I have added all the required steps as below but when application is getting deployed not seeing any logs specific to liquibase and the changeSet are not getting executed . Please help do debug the issue .

1.db.changelog-master.xml (created under resources/db/changelog )

  <preConditions>
    <not>
      <tableExists tableName="table1"/>
    </not>
  </preConditions>
  <changeSet id="1" author="name">
    <createTable tableName="category">
      <column name="id" type="int" autoIncrement="true">
        <constraints primaryKey="true" nullable="false"/>
      </column>
      <column name="name" type="varchar(250)">
        <constraints unique="true" nullable="false"/>
      </column>
    </createTable>
  </changeSet>
</databaseChangeLog>
  1. application.properties
#Liquibase configuration
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://aws-aurora-conn-url:3306/database-name
spring.datasource.username=usename
spring.datasource.password=password
spring.liquibase.change-log=classpath:db/changelog/db.changelog-master.xml
spring.liquibase.enabled=true

  1. build.gradle added these dependencies
  implementation 'org.liquibase:liquibase-core'
  implementation 'mysql:mysql-connector-java'

Thanks in advance


Solution

  • Issue was due to precondition check failure. Added the condition check in db.changelog-master.xml and was able to connect it . this will not fail the application instance instead its logs it and proceed

      <preConditions onFail="WARN">
        <not>
          <tableExists tableName="table1"/>
        </not>