mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-17 10:41:56 +08:00
Update TableDifference
This commit is contained in:
parent
fc6e5ef8ad
commit
fbbc5fcd82
@ -86,7 +86,7 @@ namespace SqlSugar
|
|||||||
z.DecimalDigits != y.DecimalDigits
|
z.DecimalDigits != y.DecimalDigits
|
||||||
))).Select(it => new DiffColumsInfo()
|
))).Select(it => new DiffColumsInfo()
|
||||||
{
|
{
|
||||||
Message=GetColumnString(it)
|
Message= GetUpdateColumnString(it, tableInfo.OldColumnInfos.FirstOrDefault(y => y.DbColumnName.EqualCase(it.DbColumnName)))
|
||||||
}).ToList();
|
}).ToList();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -102,6 +102,40 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return $"{it.DbColumnName} {it.DataType} {it.Length} {it.Scale} default:{it.DefaultValue} description:{it.ColumnDescription} pk:{it.IsPrimarykey} nullable:{it.IsNullable} identity:{it.IsIdentity} ";
|
return $"{it.DbColumnName} {it.DataType} {it.Length} {it.Scale} default:{it.DefaultValue} description:{it.ColumnDescription} pk:{it.IsPrimarykey} nullable:{it.IsNullable} identity:{it.IsIdentity} ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetUpdateColumnString(DbColumnInfo it,DbColumnInfo old)
|
||||||
|
{
|
||||||
|
var result= $"{it.DbColumnName} changes: ";
|
||||||
|
if (it.DataType != old.DataType)
|
||||||
|
{
|
||||||
|
result += $" [DataType:{old.DataType}->{it.DataType}] ";
|
||||||
|
}
|
||||||
|
if (it.Length != old.Length)
|
||||||
|
{
|
||||||
|
result += $" [Length:{old.Length}->{it.Length}] ";
|
||||||
|
}
|
||||||
|
if (it.Scale != old.Scale)
|
||||||
|
{
|
||||||
|
result += $" [Scale:{old.Scale}->{it.Scale}] ";
|
||||||
|
}
|
||||||
|
if (it.ColumnDescription != old.ColumnDescription)
|
||||||
|
{
|
||||||
|
result += $" [Description:{old.ColumnDescription}->{it.ColumnDescription}] ";
|
||||||
|
}
|
||||||
|
if (it.IsPrimarykey != old.IsPrimarykey)
|
||||||
|
{
|
||||||
|
result += $" [Pk:{old.IsPrimarykey}->{it.IsPrimarykey}] ";
|
||||||
|
}
|
||||||
|
if (it.IsNullable != old.IsNullable)
|
||||||
|
{
|
||||||
|
result += $" [Nullable:{old.IsNullable}->{it.IsNullable}] ";
|
||||||
|
}
|
||||||
|
if (it.IsIdentity != old.IsIdentity)
|
||||||
|
{
|
||||||
|
result += $" [Identity:{old.IsIdentity}->{it.IsIdentity}] ";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public class TableDifferenceInfo
|
public class TableDifferenceInfo
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user