mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 12:03:51 +08:00
#17445 - Fixing index management in data migrations
--HG-- branch : dev extra : transplant_source : %C08yTv%40%C4%BERtb%5DL%5B%BA%81%3B%DA%DD%F9
This commit is contained in:
@@ -28,6 +28,7 @@ using Orchard.FileSystems.AppData;
|
||||
using Orchard.FileSystems.Dependencies;
|
||||
using Orchard.Tests.ContentManagement;
|
||||
using Orchard.Data.Providers;
|
||||
using Orchard.Tests.DataMigration.Utilities;
|
||||
using Orchard.Tests.FileSystems.AppData;
|
||||
using Orchard.Tests.Modules.Migrations.Orchard.Tests.DataMigration.Records;
|
||||
using Path = Bleroy.FluentPath.Path;
|
||||
|
||||
@@ -19,6 +19,7 @@ using Orchard.Environment.Extensions.Folders;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Tests.ContentManagement;
|
||||
using Orchard.Data.Providers;
|
||||
using Orchard.Tests.DataMigration.Utilities;
|
||||
using Orchard.Tests.Stubs;
|
||||
|
||||
namespace Orchard.Tests.DataMigration {
|
||||
|
||||
@@ -21,7 +21,7 @@ using Orchard.Tests.Stubs;
|
||||
|
||||
namespace Orchard.Tests.DataMigration {
|
||||
[TestFixture]
|
||||
public class SchemaBuilderTests {
|
||||
public class SchemaBuilderTestsBase {
|
||||
private IContainer _container;
|
||||
private ISessionFactory _sessionFactory;
|
||||
private string _databaseFileName;
|
||||
@@ -63,8 +63,6 @@ namespace Orchard.Tests.DataMigration {
|
||||
[Test]
|
||||
public void AllMethodsShouldBeCalledSuccessfully() {
|
||||
|
||||
_schemaBuilder = new SchemaBuilder(new NullInterpreter());
|
||||
|
||||
_schemaBuilder
|
||||
.CreateTable("User", table => table
|
||||
.ContentPartRecord()
|
||||
@@ -75,19 +73,17 @@ namespace Orchard.Tests.DataMigration {
|
||||
.Column("City", DbType.String)
|
||||
.Column("ZIP", DbType.Int32, column => column.Unique())
|
||||
.Column("UserId", DbType.Int32, column => column.NotNull()))
|
||||
.CreateForeignKey("User_Address", "User", new[] { "UserId" }, "User", new[] { "Id" })
|
||||
.CreateForeignKey("User_Address", "Address", new[] { "UserId" }, "User", new[] { "Id" })
|
||||
.AlterTable("User", table => table
|
||||
.AddColumn("Age", DbType.Int32))
|
||||
.AlterTable("User", table => table
|
||||
.DropColumn("Lastname"))
|
||||
.AlterTable("User", table => table
|
||||
.CreateIndex("IDX_XYZ", "NickName"))
|
||||
.CreateIndex("IDX_XYZ", "Firstname"))
|
||||
.AlterTable("User", table => table
|
||||
.DropIndex("IDX_XYZ"))
|
||||
.DropForeignKey("Address", "User_Address")
|
||||
.DropTable("Address")
|
||||
.ExecuteSql("drop database", statement => statement.ForProvider("SqlCe"))
|
||||
.ExecuteSql("DROP DATABASE", statement => statement.ForProvider("SQLServer"));
|
||||
.DropTable("Address");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
using Orchard.Data.Migration.Interpreters;
|
||||
using Orchard.Data.Migration.Schema;
|
||||
|
||||
public class NullInterpreter : IDataMigrationInterpreter {
|
||||
namespace Orchard.Tests.DataMigration.Utilities {
|
||||
public class NullInterpreter : IDataMigrationInterpreter {
|
||||
|
||||
public void Visit(ISchemaBuilderCommand command) {
|
||||
}
|
||||
public void Visit(ISchemaBuilderCommand command) {
|
||||
}
|
||||
|
||||
public void Visit(CreateTableCommand command) {
|
||||
}
|
||||
public void Visit(CreateTableCommand command) {
|
||||
}
|
||||
|
||||
public void Visit(DropTableCommand command) {
|
||||
}
|
||||
public void Visit(DropTableCommand command) {
|
||||
}
|
||||
|
||||
public void Visit(AlterTableCommand command) {
|
||||
}
|
||||
public void Visit(AlterTableCommand command) {
|
||||
}
|
||||
|
||||
public void Visit(SqlStatementCommand command) {
|
||||
}
|
||||
public void Visit(SqlStatementCommand command) {
|
||||
}
|
||||
|
||||
public void Visit(CreateForeignKeyCommand command) {
|
||||
}
|
||||
public void Visit(CreateForeignKeyCommand command) {
|
||||
}
|
||||
|
||||
public void Visit(DropForeignKeyCommand command) {
|
||||
public void Visit(DropForeignKeyCommand command) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendFormat("alter table {0} add index {1} ({2}) ",
|
||||
builder.AppendFormat("create index {1} on {0} ({2}) ",
|
||||
_dialect.QuoteForTableName(PrefixTableName(command.TableName)),
|
||||
_dialect.QuoteForColumnName(command.IndexName),
|
||||
String.Join(", ", command.ColumnNames));
|
||||
@@ -224,7 +224,7 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendFormat("alter table {0} drop index {1}",
|
||||
builder.AppendFormat("drop index {0}.{1}",
|
||||
_dialect.QuoteForTableName(PrefixTableName(command.TableName)),
|
||||
_dialect.QuoteForColumnName(command.IndexName));
|
||||
_sqlStatements.Add(builder.ToString());
|
||||
|
||||
Reference in New Issue
Block a user