Table name should not include the prefix: Orchard_Blogs_BlogArchiveRecord during Data Migration scaffolding

--HG--
branch : dev
This commit is contained in:
Sebastien Ros 2010-07-07 17:29:06 -07:00
parent 0cf950bc83
commit db85727d0a
3 changed files with 12 additions and 6 deletions

View File

@ -5,7 +5,7 @@ namespace $$FeatureName$$.DataMigrations {
public class $$ClassName$$DataMigration : DataMigrationImpl { public class $$ClassName$$DataMigration : DataMigrationImpl {
public int Create() { public int Create() {
$$Commands$$ $$Commands$$
return 0100; return 0100;
} }

View File

@ -13,7 +13,7 @@ namespace Orchard.DevTools.Services {
} }
public override void Visit(CreateTableCommand command) { public override void Visit(CreateTableCommand command) {
_output.WriteLine("// Creating table {0}", command.Name); _output.WriteLine("\t\t\t// Creating table {0}", command.Name);
_output.WriteLine("\t\t\tSchemaBuilder.CreateTable(\"{0}\", table => table", command.Name); _output.WriteLine("\t\t\tSchemaBuilder.CreateTable(\"{0}\", table => table", command.Name);
foreach ( var createColumn in command.TableCommands.OfType<CreateColumnCommand>() ) { foreach ( var createColumn in command.TableCommands.OfType<CreateColumnCommand>() ) {

View File

@ -34,14 +34,20 @@ namespace Orchard.Data.Migration.Generator {
// get the tables using reflection // get the tables using reflection
var tablesField = typeof(Configuration).GetField("tables", BindingFlags.Instance | BindingFlags.NonPublic); var tablesField = typeof(Configuration).GetField("tables", BindingFlags.Instance | BindingFlags.NonPublic);
var tables = ((IDictionary<string, Table>) tablesField.GetValue(configuration)).Values; var tables = ((IDictionary<string, Table>) tablesField.GetValue(configuration)).Values;
string prefix = feature.Replace(".", "_") + "_";
foreach(var table in tables.Where(t => parameters.RecordDescriptors.Any(rd => rd.Feature.Descriptor.Name == feature && rd.TableName == t.Name))) { foreach(var table in tables.Where(t => parameters.RecordDescriptors.Any(rd => rd.Feature.Descriptor.Name == feature && rd.TableName == t.Name))) {
if(drop) { string tableName = table.Name;
yield return new DropTableCommand(table.Name); if(tableName.StartsWith(prefix)) {
tableName = tableName.Substring(prefix.Length);
} }
var command = new CreateTableCommand(table.Name); if(drop) {
yield return new DropTableCommand(tableName);
}
var command = new CreateTableCommand(tableName);
foreach(var column in table.ColumnIterator) { foreach(var column in table.ColumnIterator) {
var table1 = table; var table1 = table;