mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-18 19:51:45 +08:00
Fix bug with table prefix in data migration
We weren't adding the "_" after the table prefix... --HG-- branch : dev
This commit is contained in:
@@ -61,7 +61,7 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
|
||||
builder.Append(_dialect.CreateMultisetTableString)
|
||||
.Append(' ')
|
||||
.Append(_dialect.QuoteForTableName(_shellSettings.DataTablePrefix + command.Name))
|
||||
.Append(_dialect.QuoteForTableName(PrefixTableName(command.Name)))
|
||||
.Append(" (");
|
||||
|
||||
var appendComma = false;
|
||||
@@ -92,6 +92,12 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
RunPendingStatements();
|
||||
}
|
||||
|
||||
private string PrefixTableName(string tableName) {
|
||||
if (string.IsNullOrEmpty(_shellSettings.DataTablePrefix))
|
||||
return tableName;
|
||||
return _shellSettings.DataTablePrefix + "_" + tableName;
|
||||
}
|
||||
|
||||
public override void Visit(DropTableCommand command) {
|
||||
if (ExecuteCustomInterpreter(command)) {
|
||||
return;
|
||||
@@ -99,7 +105,7 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
|
||||
var builder = new StringBuilder();
|
||||
|
||||
builder.Append(_dialect.GetDropTableString(_shellSettings.DataTablePrefix + command.Name));
|
||||
builder.Append(_dialect.GetDropTableString(PrefixTableName(command.Name)));
|
||||
_sqlStatements.Add(builder.ToString());
|
||||
|
||||
RunPendingStatements();
|
||||
@@ -156,7 +162,7 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendFormat("alter table {0} add column ", _dialect.QuoteForTableName(_shellSettings.DataTablePrefix + command.TableName));
|
||||
builder.AppendFormat("alter table {0} add column ", _dialect.QuoteForTableName(PrefixTableName(command.TableName)));
|
||||
|
||||
Visit(builder, (CreateColumnCommand)command);
|
||||
_sqlStatements.Add(builder.ToString());
|
||||
@@ -168,7 +174,7 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
}
|
||||
|
||||
builder.AppendFormat("alter table {0} drop column {1}",
|
||||
_dialect.QuoteForTableName(_shellSettings.DataTablePrefix + command.TableName),
|
||||
_dialect.QuoteForTableName(PrefixTableName(command.TableName)),
|
||||
_dialect.QuoteForColumnName(command.ColumnName));
|
||||
_sqlStatements.Add(builder.ToString());
|
||||
}
|
||||
@@ -179,7 +185,7 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
}
|
||||
|
||||
builder.AppendFormat("alter table {0} alter column {1} ",
|
||||
_dialect.QuoteForTableName(_shellSettings.DataTablePrefix + command.TableName),
|
||||
_dialect.QuoteForTableName(PrefixTableName(command.TableName)),
|
||||
_dialect.QuoteForColumnName(command.TableName));
|
||||
|
||||
// type
|
||||
@@ -201,7 +207,7 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
}
|
||||
|
||||
builder.AppendFormat("alter table {0} add index {1} ({2}) ",
|
||||
_dialect.QuoteForTableName(_shellSettings.DataTablePrefix + command.TableName),
|
||||
_dialect.QuoteForTableName(PrefixTableName(command.TableName)),
|
||||
_dialect.QuoteForColumnName(command.IndexName),
|
||||
String.Join(", ", command.ColumnNames));
|
||||
|
||||
@@ -214,7 +220,7 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
}
|
||||
|
||||
builder.AppendFormat("alter table {0} drop index {1}",
|
||||
_dialect.QuoteForTableName(_shellSettings.DataTablePrefix + command.TableName),
|
||||
_dialect.QuoteForTableName(PrefixTableName(command.TableName)),
|
||||
_dialect.QuoteForColumnName(command.IndexName));
|
||||
_sqlStatements.Add(builder.ToString());
|
||||
}
|
||||
@@ -240,7 +246,7 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
var builder = new StringBuilder();
|
||||
|
||||
builder.Append("alter table ")
|
||||
.Append(_dialect.QuoteForTableName(_shellSettings.DataTablePrefix + command.SrcTable));
|
||||
.Append(_dialect.QuoteForTableName(PrefixTableName(command.SrcTable)));
|
||||
|
||||
builder.Append(_dialect.GetAddForeignKeyConstraintString(command.Name,
|
||||
command.SrcColumns,
|
||||
|
||||
Reference in New Issue
Block a user