Merge pull request #5338 from qt1/IBN-Labs/Schemabuilder.TableDbName

Provide full table name prefix for migrations
This commit is contained in:
Sébastien Ros
2015-06-04 12:32:30 -07:00
4 changed files with 14 additions and 1 deletions

View File

@@ -24,5 +24,10 @@ namespace Orchard.Tests.DataMigration.Utilities {
public void Visit(DropForeignKeyCommand command) {
}
public string PrefixTableName(string tableName) {
return tableName;
}
}
}

View File

@@ -91,7 +91,7 @@ namespace Orchard.Data.Migration.Interpreters {
RunPendingStatements();
}
private string PrefixTableName(string tableName) {
public string PrefixTableName(string tableName) {
if (string.IsNullOrEmpty(_shellSettings.DataTablePrefix))
return tableName;
return _shellSettings.DataTablePrefix + "_" + tableName;

View File

@@ -9,5 +9,6 @@ namespace Orchard.Data.Migration.Interpreters {
void Visit(SqlStatementCommand command);
void Visit(CreateForeignKeyCommand command);
void Visit(DropForeignKeyCommand command);
string PrefixTableName(string tableName);
}
}

View File

@@ -28,6 +28,13 @@ namespace Orchard.Data.Migration.Schema {
public Func<string, string> FormatPrefix {
get { return _formatPrefix; }
}
/// <summary>
/// Translate Table name into database table name - including prefixes
/// </summary>
public virtual string TableDbName(string srcTable) {
return _interpreter.PrefixTableName(String.Concat(FormatPrefix(FeaturePrefix), srcTable));
}
public SchemaBuilder CreateTable(string name, Action<CreateTableCommand> table) {
var createTable = new CreateTableCommand(String.Concat(_formatPrefix(_featurePrefix), name));