我使用liquibase来管理db迁移。现在,我有一个脚本来修改列定义,如下所示
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">
select count(*) from (
select generation_expression from `information_schema`.`columns`
where table_schema = (select DATABASE() from DUAL) and TABLE_NAME = 'MyTable' and Column_name = 'numericValue1'
) temp
where generation_expression like '%STRING%';
</sqlCheck>
</preConditions>
<sql>
ALTER TABLE `MyTable`
MODIFY `numericValue1` double GENERATED ALWAYS AS ((case when (json_type(json_extract(`object`,'$.numericValue1')) = 'NULL') OR (json_type(json_extract(`object`,'$.numericValue1')) = 'STRING') then NULL else json_unquote(json_extract(`object`,'$.numericValue1')) end)) VIRTUAL;
</sql>
然而,它失败的原因
Reason: liquibase.exception.DatabaseException: Data truncated for column 'numericValue1' at row 5030 [Failed SQL: ALTER TABLE `MyTable` .....
我看到这个了 Data truncated for column 'numericValue1'
当我在workbench中手动测试脚本时出现警告消息,我希望会出现这种情况。然而,liquibase似乎不像警告那样失败了。是否有必要告诉liquibase忽略警告并运行sql脚本?
谢谢。
暂无答案!
目前还没有任何答案,快来回答吧!