yaml配置对liquibase不起作用

huangapple go评论87阅读模式
英文:

yaml configuration for liquibase not working

问题

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

application.properties 中的 service.entities.migration.enabled 为 false。

英文:

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

得分: 1

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)
英文:

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)

huangapple
  • 本文由 发表于 2023年7月17日 18:23:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76703521.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定