mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixed [default value] For Mysql
The [default value] can'nt use [modify column] in mysql.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using NHibernate.Dialect;
|
||||
@@ -34,6 +35,7 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
builder.AppendFormat("alter table {0} modify column {1} ",
|
||||
_dialectLazy.Value.QuoteForTableName(PrefixTableName(command.TableName)),
|
||||
_dialectLazy.Value.QuoteForColumnName(command.ColumnName));
|
||||
var initLength = builder.Length;
|
||||
|
||||
// type
|
||||
if (command.DbType != DbType.Object) {
|
||||
@@ -46,13 +48,31 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
}
|
||||
|
||||
// [default value]
|
||||
var builder2 = new StringBuilder();
|
||||
|
||||
builder2.AppendFormat("alter table {0} alter column {1} ",
|
||||
_dialectLazy.Value.QuoteForTableName(PrefixTableName(command.TableName)),
|
||||
_dialectLazy.Value.QuoteForColumnName(command.ColumnName));
|
||||
var initLength2 = builder2.Length;
|
||||
|
||||
if (command.Default != null) {
|
||||
builder.Append(" set default ").Append(DefaultDataMigrationInterpreter.ConvertToSqlValue(command.Default)).Append(" ");
|
||||
builder2.Append(" set default ").Append(DefaultDataMigrationInterpreter.ConvertToSqlValue(command.Default)).Append(" ");
|
||||
}
|
||||
|
||||
return new [] {
|
||||
builder.ToString()
|
||||
};
|
||||
// result
|
||||
var result = new List<string>();
|
||||
|
||||
if (builder.Length > initLength)
|
||||
{
|
||||
result.Add(builder.ToString());
|
||||
}
|
||||
|
||||
if (builder2.Length > initLength2)
|
||||
{
|
||||
result.Add(builder2.ToString());
|
||||
}
|
||||
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
private string PrefixTableName(string tableName) {
|
||||
|
Reference in New Issue
Block a user