Fixes: U4-4463 Upgrade 6.2.0 > 7.1.0 fails - due to incorrect formatting of foreign keys for sql servers
Conflicts: src/Umbraco.Tests/Migrations/AlterMigrationTests.cs src/Umbraco.Tests/Migrations/Stubs/AlterUserTableMigrationStub.cs
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
@@ -41,7 +42,7 @@ namespace Umbraco.Core.Persistence.Migrations.Syntax.Delete.Expressions
|
||||
|
||||
if (string.IsNullOrEmpty(ForeignKey.Name))
|
||||
{
|
||||
ForeignKey.Name = string.Format("FK_{0}_{1}", ForeignKey.ForeignTable, ForeignKey.PrimaryTable);
|
||||
ForeignKey.Name = string.Format("FK_{0}_{1}_{2}", ForeignKey.ForeignTable, ForeignKey.PrimaryTable, ForeignKey.PrimaryColumns.First());
|
||||
}
|
||||
|
||||
return string.Format(SqlSyntaxContext.SqlSyntaxProvider.DeleteConstraint,
|
||||
|
||||
@@ -17,6 +17,22 @@ namespace Umbraco.Tests.Migrations
|
||||
SqlSyntaxContext.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Drop_Foreign_Key()
|
||||
{
|
||||
// Arrange
|
||||
var context = new MigrationContext(DatabaseProviders.SqlServerCE, null);
|
||||
var stub = new DropForeignKeyMigrationStub();
|
||||
|
||||
// Act
|
||||
stub.GetUpExpressions(context);
|
||||
|
||||
// Assert
|
||||
Assert.That(context.Expressions.Count(), Is.EqualTo(1));
|
||||
Assert.That(context.Expressions.Single().ToString(), Is.EqualTo("ALTER TABLE [umbracoUser2app] DROP CONSTRAINT [FK_umbracoUser2app_umbracoUser_id]"));
|
||||
|
||||
}
|
||||
|
||||
[NUnit.Framework.Ignore("this doesn't actually test anything")]
|
||||
[Test]
|
||||
public void Can_Get_Up_Migration_From_MigrationStub()
|
||||
|
||||
@@ -13,6 +13,18 @@ namespace Umbraco.Tests.Migrations.Stubs
|
||||
.Nullable();
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
}
|
||||
}
|
||||
[MigrationAttribute("1.0.0", 0, "Test")]
|
||||
public class DropForeignKeyMigrationStub : MigrationBase
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
Delete.ForeignKey().FromTable("umbracoUser2app").ForeignColumn("user").ToTable("umbracoUser").PrimaryColumn("id");
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
|
||||
Reference in New Issue
Block a user