Fixes: U4-4463 Upgrade 6.2.0 > 7.1.0 fails - due to incorrect formatting of foreign keys for sql servers
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,7 +17,6 @@ namespace Umbraco.Tests.Migrations
|
||||
SqlSyntaxContext.SqlSyntaxProvider = SqlCeSyntax.Provider;
|
||||
}
|
||||
|
||||
[NUnit.Framework.Ignore("this doesn't actually test anything")]
|
||||
[Test]
|
||||
public void Drop_Foreign_Key()
|
||||
{
|
||||
@@ -29,15 +28,9 @@ namespace Umbraco.Tests.Migrations
|
||||
stub.GetUpExpressions(context);
|
||||
|
||||
// Assert
|
||||
Assert.That(context.Expressions.Any(), Is.True);
|
||||
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]"));
|
||||
|
||||
//Console output
|
||||
Console.WriteLine("Number of expressions in context: {0}", context.Expressions.Count);
|
||||
Console.WriteLine("");
|
||||
foreach (var expression in context.Expressions)
|
||||
{
|
||||
Console.WriteLine(expression.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
[NUnit.Framework.Ignore("this doesn't actually test anything")]
|
||||
|
||||
@@ -19,12 +19,12 @@ namespace Umbraco.Tests.Migrations.Stubs
|
||||
}
|
||||
|
||||
|
||||
[MigrationAttribute("6.0.0", 0, "Test")]
|
||||
[MigrationAttribute("1.0.0", 0, "Test")]
|
||||
public class DropForeignKeyMigrationStub : MigrationBase
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
Delete.ForeignKey().FromTable("umbracoUser2app").ForeignColumn("app").ToTable("umbracoApp").PrimaryColumn("appAlias");
|
||||
Delete.ForeignKey().FromTable("umbracoUser2app").ForeignColumn("user").ToTable("umbracoUser").PrimaryColumn("id");
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
|
||||
Reference in New Issue
Block a user