|
|
@ -586,10 +586,8 @@ namespace SqlSugar |
|
|
|
} |
|
|
|
if (defaultValue.ToLower().IsIn("now()", "current_timestamp","null") || defaultValue.ToLower().Contains("current_timestamp")|| defaultValue.Contains("()")) |
|
|
|
{ |
|
|
|
string template = "ALTER table {0} CHANGE COLUMN {1} {1} {3} {4} default {2} COMMENT '{5}'"; |
|
|
|
var dbColumnInfo = this.Context.DbMaintenance.GetColumnInfosByTableName(tableName,false).First(it => it.DbColumnName.Equals(columnName, StringComparison.CurrentCultureIgnoreCase)); |
|
|
|
var value = Regex.Match(defaultValue, @"\(\d\)$").Value; |
|
|
|
string sql = string.Format(template, tableName, columnName, defaultValue, dbColumnInfo.DataType + value, dbColumnInfo.IsNullable ? " NULL " : " NOT NULL ", dbColumnInfo.ColumnDescription); |
|
|
|
defaultValue = "(" + defaultValue + ")"; |
|
|
|
string sql = string.Format(AddDefaultValueSql.Replace("'", ""), tableName, columnName, defaultValue); |
|
|
|
this.Context.Ado.ExecuteCommand(sql); |
|
|
|
return true; |
|
|
|
} |
|
|
|