Fix bad LockDto primary key w/migration

This commit is contained in:
Stephan
2018-10-17 15:09:00 +02:00
parent 71cec84f78
commit e80ea9830c
3 changed files with 25 additions and 0 deletions

View File

@@ -137,6 +137,7 @@ namespace Umbraco.Core.Migrations.Upgrade
// resume at {290C18EE-B3DE-4769-84F1-1F467F3F76DA}...
Chain<DropTaskTables>("{6A2C7C1B-A9DB-4EA9-B6AB-78E7D5B722A7}");
Chain<FixLockTablePrimaryKey>("{77874C77-93E5-4488-A404-A630907CEEF0}");
//FINAL

View File

@@ -0,0 +1,23 @@
using System.Linq;
namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
{
public class FixLockTablePrimaryKey : MigrationBase
{
public FixLockTablePrimaryKey(IMigrationContext context)
: base(context)
{ }
public override void Migrate()
{
// at some point, the KeyValueService dropped the PK and failed to re-create it,
// so the PK is gone - make sure we have one, and create if needed
var constraints = SqlSyntax.GetConstraintsPerTable(Database);
var exists = constraints.Any(x => x.Item2 == "PK_umbracoLock");
if (!exists)
Create.PrimaryKey("PK_umbracoLock").OnTable(Constants.DatabaseSchema.Tables.Lock).Column("id").Do();
}
}
}

View File

@@ -357,6 +357,7 @@
<Compile Include="Migrations\Upgrade\V_8_0_0\AddVariationTables2.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\DataTypeMigration.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\DropTaskTables.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\FixLockTablePrimaryKey.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\LanguageColumns.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\PropertyEditorsMigration.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\RefactorMacroColumns.cs" />