Liquibase将错误的默认日期值插入MySql

问题描述

我有变更日志:

<databaseChangeLog
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
                      http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.0.xsd">
    <changeSet  id="10" author="vaa25">
        <createTable tableName="test" schemaName="liquibase">
            <column name="id" type="INT" autoIncrement="true">
                <constraints primaryKey="true"/>
            </column>
            <column name="created_at" type="DATETIME(3)" defaultValueDate="CURRENT_TIMESTAMP(3)">
                <constraints nullable="false"/>
            </column>
        </createTable>
    </changeSet>
</databaseChangeLog>

执行结果: liquibase.exception.DatabaseException: Invalid default value for 'created_at' [Failed sql: (1067) CREATE TABLE liquibase.test (id INT AUTO_INCREMENT NOT NULL,created_at datetime(3) DEFAULT Now() NOT NULL,CONSTRAINT PK_TEST PRIMARY KEY (id))]

原因:liquibase用Now()代替Now(3)。

是的,我当然可以使用正确的本机sql脚本应用“ sql标签,但无论如何似乎是liquibase错误。使用了Liquibase 4.0.0和MysqL 8.0.15。

这是更多的错误报告,然后是问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)