如果新字段是非空,但是没有默认值,那么强制改为允许空。解决数据库表升级时,在原有表中新增非空有默认值字段时,不能自动正确生成相关sql语句的问题。

This commit is contained in:
xueshaoyu 2025-07-23 11:13:02 +08:00 committed by GitHub
parent 5afc017bf1
commit 7c442f0f05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -237,7 +237,9 @@ internal partial class DbMetaData
//return String.Empty;
// 非空字段作为可空字段新增,避开重建表
item.Nullable = true;
// 如果新字段是非空,但是没有默认值,那么强制改为允许空
if (item.DefaultValue == null)
item.Nullable = true;
}
PerformSchema(sb, @readonly, DDLSchema.AddColumn, item);