yaml配置对liquibase不起作用

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

yaml configuration for liquibase not working

问题

  1. databaseChangeLog:
  2. - changeSet:
  3. id: send_service_entities
  4. author: test
  5. comment: "Sending service entities"
  6. preConditions:
  7. - onFail: CONTINUE
  8. changeLogPropertyDefined:
  9. property: service.entities.migration.enabled
  10. value: true
  11. changes:
  12. - customChange:
  13. class: "com.testproject.migration.v2.ServiceEntitiesMigrationCustomChange"
  14. 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

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
  5. http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
  6. <changeSet id="send_service_entities" author="test">
  7. <preConditions onFail="CONTINUE">
  8. <changeLogPropertyDefined property="service.entities.migration.enabled" value="true"/>
  9. </preConditions>
  10. <comment>Sending service entities</comment>
  11. <customChange class="com.testproject.migration.v2.ServiceEntitiesMigrationCustomChange">
  12. <param name="serviceName" value="${spring.application.name}"/>
  13. </customChange>
  14. </changeSet>
  15. </databaseChangeLog>

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

  1. databaseChangeLog:
  2. - changeSet:
  3. id: send_service_entities
  4. author: test
  5. comment: "Sending service entities"
  6. preConfition:
  7. - onFail: CONTINUE
  8. - changeLogPropertyDefined:
  9. property: service.entities.migration.enabled
  10. value: true
  11. changes:
  12. - customChange : {
  13. "class": "com.testproject.migration.v2.ServiceEntitiesMigrationCustomChange",
  14. "serviceName": "${spring.application.name}"
  15. }

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:

  1. databaseChangeLog:
  2. - preConditions:
  3. - dbms:
  4. type: oracle
  5. - runningAs:
  6. username: SYSTEM
  7. - changeSet:
  8. id: 1
  9. author: Liquibase User
  10. preConditions:
  11. - onFail: WARN
  12. - sqlCheck:
  13. expectedResult: 0
  14. sql: SELECT COUNT(*) FROM example_table
  15. comment: Comments should go after the precondition. Otherwise, Liquibase returns an error.
  16. changes:
  17. - createTable:
  18. tableName: example_table
  19. columns:
  20. - column:
  21. name: id
  22. type: int
  23. autoIncrement: true
  24. constraints:
  25. primaryKey: true
  26. nullable: false
  27. - column:
  28. name: firstname
  29. type: varchar(50)
  30. - column:
  31. name: lastname
  32. type: varchar(50)
  33. constraints:
  34. nullable: false
  35. - column:
  36. name: state
  37. 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:

确定