英文:
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
- dbms:
- 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)
- column:
- createTable:
英文:
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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论