yaml configuration for liquibase not working

94 Views Asked by At

I have a configuration that is written in xml and it works great, but I want to convert it to yaml format, but I get an error.

xml config

<?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.0.xsd">
<changeSet id="send_service_entities" author="test">
    <preConditions onFail="CONTINUE">
        <changeLogPropertyDefined property="service.entities.migration.enabled" value="true"/>
    </preConditions>
    <comment>Sending service entities</comment>
    <customChange class="com.testproject.migration.v2.ServiceEntitiesMigrationCustomChange">
        <param name="serviceName" value="${spring.application.name}"/>
    </customChange>
</changeSet>
</databaseChangeLog>

yaml config, liquibase seems to ignore "preConfition" and jump to the "changes" parameter

databaseChangeLog:
 - changeSet:
      id:  send_service_entities
      author:  test
      comment: "Sending service entities"
      preConfition:
        - onFail: CONTINUE
        - changeLogPropertyDefined:
            property: service.entities.migration.enabled
            value: true
      changes:
      - customChange : {
           "class": "com.testproject.migration.v2.ServiceEntitiesMigrationCustomChange",
           "serviceName": "${spring.application.name}"
      }

service.entities.migration.enabled in application.properties is false

1

There are 1 best solutions below

0
htshame On BEST ANSWER

You have a typo in yaml changeSet: preConfition instead of preConditions

Check out yaml example for preConditions:

databaseChangeLog:
 - preConditions:
     - dbms:
        type: oracle
     - runningAs:
        username: SYSTEM
 - changeSet:
     id:  1
     author: Liquibase User
     preConditions:
       - onFail: WARN
       - sqlCheck:
          expectedResult: 0
          sql: SELECT COUNT(*) FROM example_table
     comment: Comments should go after the precondition. Otherwise, Liquibase returns an error.
     changes:
     - createTable:
         tableName: example_table
         columns:
          - column:
             name: id
             type: int
             autoIncrement: true
             constraints:
              primaryKey: true
              nullable: false
          - column:
             name:  firstname
             type:  varchar(50)
          - column:
             name:  lastname
             type:  varchar(50)
             constraints:
              nullable:  false
          - column:
             name:  state
             type:  char(2)