mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
- 修复 pgsql varchar(120) CodeFirst 迁移不修改长度;
This commit is contained in:
@ -229,7 +229,19 @@ where ns.nspname = {0} and c.relname = {1}", tboldname ?? tbname);
|
||||
string.IsNullOrEmpty(tbcol.Attribute.OldName) == false && tbstruct.TryGetValue(tbcol.Attribute.OldName, out tbstructcol))
|
||||
{
|
||||
var isCommentChanged = tbstructcol.comment != (tbcol.Comment ?? "");
|
||||
if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false ||
|
||||
var sqlTypeSize = tbstructcol.sqlType;
|
||||
if (sqlTypeSize.Contains("(") == false)
|
||||
{
|
||||
switch (sqlTypeSize.ToLower())
|
||||
{
|
||||
case "bit":
|
||||
case "varbit":
|
||||
case "bpchar":
|
||||
case "varchar":
|
||||
sqlTypeSize = $"{sqlTypeSize}({tbstructcol.max_length})"; break;
|
||||
}
|
||||
}
|
||||
if (tbcol.Attribute.DbType.StartsWith(sqlTypeSize, StringComparison.CurrentCultureIgnoreCase) == false ||
|
||||
tbcol.Attribute.DbType.Contains("[]") != (tbstructcol.attndims > 0))
|
||||
sbalter.Append("ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" ALTER COLUMN ").Append(_commonUtils.QuoteSqlName(tbstructcol.column)).Append(" TYPE ").Append(tbcol.Attribute.DbType.Split(' ').First()).Append(";\r\n");
|
||||
if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable)
|
||||
|
@ -241,7 +241,19 @@ where ns.nspname = {0} and c.relname = {1}", tboldname ?? tbname);
|
||||
string.IsNullOrEmpty(tbcol.Attribute.OldName) == false && tbstruct.TryGetValue(tbcol.Attribute.OldName, out tbstructcol))
|
||||
{
|
||||
var isCommentChanged = tbstructcol.comment != (tbcol.Comment ?? "");
|
||||
if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false ||
|
||||
var sqlTypeSize = tbstructcol.sqlType;
|
||||
if (sqlTypeSize.Contains("(") == false)
|
||||
{
|
||||
switch (sqlTypeSize.ToLower())
|
||||
{
|
||||
case "bit":
|
||||
case "varbit":
|
||||
case "bpchar":
|
||||
case "varchar":
|
||||
sqlTypeSize = $"{sqlTypeSize}({tbstructcol.max_length})"; break;
|
||||
}
|
||||
}
|
||||
if (tbcol.Attribute.DbType.StartsWith(sqlTypeSize, StringComparison.CurrentCultureIgnoreCase) == false ||
|
||||
tbcol.Attribute.DbType.Contains("[]") != (tbstructcol.attndims > 0))
|
||||
sbalter.Append("ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" ALTER COLUMN ").Append(_commonUtils.QuoteSqlName(tbstructcol.column)).Append(" TYPE ").Append(tbcol.Attribute.DbType.Split(' ').First()).Append(";\r\n");
|
||||
if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable)
|
||||
|
Reference in New Issue
Block a user