mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-08-24 05:41:44 +08:00
Table name should not include the prefix: Orchard_Blogs_BlogArchiveRecord during Data Migration scaffolding
--HG-- branch : dev
This commit is contained in:
parent
0cf950bc83
commit
db85727d0a
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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>() ) {
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user