我想在Spring Boot应用程序中使用Liquibase向MySQL插入一行数据。类似于以下内容:
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<changeSet author="laxika" id="20160508-2">
<insert tableName="news">
<column name="title" value="Hello world"/>
<column name="release_date" value="2016-05-09 00:00:00"/>
<column name="icon" value="update"/>
<column name="message" value="
a
b
c
d
"/>
</insert>
</changeSet>
</databaseChangeLog>
由于某种奇怪的原因,liquibase不能正确地将换行符添加到SQL中,因此我最终在数据库中得到了一个很长的字符串。如何强制liquibase插入换行符?
这是我尝试插入的表的模式:
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<changeSet author="laxika" id="20150922-4">
<createTable tableName="news">
<column name="id" type="smallint unsigned" autoIncrement="true">
<constraints primaryKey="true" nullable="false" />
</column>
<column name="release_date" type="date">
<constraints nullable="false" />
</column>
<column name="title" type="varchar(256)">
<constraints nullable="false" />
</column>
<column name="message" type="varchar(2048)">
<constraints nullable="false" />
</column>
<column name="icon" type="varchar(32)">
<constraints nullable="false" />
</column>
</createTable>
<modifySql>
<append value="ENGINE=INNODB DEFAULT CHARSET=utf8"/>
</modifySql>
</changeSet>
</databaseChangeLog>