Fix migrations

This commit is contained in:
Stephan
2019-05-10 10:13:23 +02:00
parent 301b16a036
commit 0b924f75d4
8 changed files with 73 additions and 76 deletions

View File

@@ -90,11 +90,11 @@ namespace Umbraco.Core.Migrations.Upgrade
//
From("{init-7.14.0}");
// begin migrating from v7 - remove all keys and indexes
To<DeleteKeysAndIndexes>("{B36B9ABD-374E-465B-9C5F-26AB0D39326F}");
To<AddLockObjects>("{7C447271-CA3F-4A6A-A913-5D77015655CB}");
To<AddContentNuTable>("{CBFF58A2-7B50-4F75-8E98-249920DB0F37}"); // fixme cascade
//To<RefactorXmlColumns>("{3D18920C-E84D-405C-A06A-B7CEE52FE5DD}"); // we're going to drop them anyways
To<RenameMediaVersionTable>("{5CB66059-45F4-48BA-BCBD-C5035D79206B}");
To<VariantsMigration>("{FB0A5429-587E-4BD0-8A67-20F0E7E62FF7}");
To<DropMigrationsTable>("{F0C42457-6A3B-4912-A7EA-F27ED85A2092}");
@@ -117,21 +117,18 @@ namespace Umbraco.Core.Migrations.Upgrade
To<UpdateDefaultMandatoryLanguage>("{5F4597F4-A4E0-4AFE-90B5-6D2F896830EB}");
To<RefactorVariantsModel>("{290C18EE-B3DE-4769-84F1-1F467F3F76DA}");
To<DropTaskTables>("{6A2C7C1B-A9DB-4EA9-B6AB-78E7D5B722A7}");
//To<FixLockTablePrimaryKey>("{77874C77-93E5-4488-A404-A630907CEEF0}"); // we're going to recreate keys at the end
To<AddLogTableColumns>("{8804D8E8-FE62-4E3A-B8A2-C047C2118C38}");
To<DropPreValueTable>("{23275462-446E-44C7-8C2C-3B8C1127B07D}");
To<DropDownPropertyEditorsMigration>("{6B251841-3069-4AD5-8AE9-861F9523E8DA}");
To<TagsMigrationFix>("{EE429F1B-9B26-43CA-89F8-A86017C809A3}");
To<DropTemplateDesignColumn>("{08919C4B-B431-449C-90EC-2B8445B5C6B1}");
To<TablesForScheduledPublishing>("{7EB0254C-CB8B-4C75-B15B-D48C55B449EB}");
//To<DropTaskTables>("{648A2D5F-7467-48F8-B309-E99CEEE00E2A}"); // duplicate (see above)
To<MakeTagsVariant>("{C39BF2A7-1454-4047-BBFE-89E40F66ED63}");
To<MakeRedirectUrlVariant>("{64EBCE53-E1F0-463A-B40B-E98EFCCA8AE2}");
To<AddContentTypeIsElementColumn>("{0009109C-A0B8-4F3F-8FEB-C137BBDDA268}");
To<ConvertRelatedLinksToMultiUrlPicker>("{ED28B66A-E248-4D94-8CDB-9BDF574023F0}");
To<UpdatePickerIntegerValuesToUdi>("{38C809D5-6C34-426B-9BEA-EFD39162595C}");
To<RenameUmbracoDomainsTable>("{6017F044-8E70-4E10-B2A3-336949692ADD}");
To<AddUserLoginDtoDateIndex>("{98339BEF-E4B2-48A8-B9D1-D173DC842BBE}");
Merge()
.To<DropXmlTables>("{CDBEDEE4-9496-4903-9CF2-4104E00FF960}")
@@ -139,12 +136,22 @@ namespace Umbraco.Core.Migrations.Upgrade
.To<RadioAndCheckboxAndDropdownPropertyEditorsMigration>("{940FD19A-00A8-4D5C-B8FF-939143585726}")
.As("{0576E786-5C30-4000-B969-302B61E90CA3}");
To<FixLanguageIsoCodeLength>("{48AD6CCD-C7A4-4305-A8AB-38728AD23FC5}");
// finish migrating from v7 - recreate all keys and indexes
To<CreateKeysAndIndexes>("{3F9764F5-73D0-4D45-8804-1240A66E43A2}");
To<RenameLabelAndRichTextPropertyEditorAliases>("{E0CBE54D-A84F-4A8F-9B13-900945FD7ED9}");
To<MergeDateAndDateTimePropertyEditor>("{78BAF571-90D0-4D28-8175-EF96316DA789}"); // release-8.0.0
To<ChangeNuCacheJsonFormat>("{80C0A0CB-0DD5-4573-B000-C4B7C313C70D}"); // release-8.0.1
To<MergeDateAndDateTimePropertyEditor>("{78BAF571-90D0-4D28-8175-EF96316DA789}");
// release-8.0.0
// to 8.0.1...
To<ChangeNuCacheJsonFormat>("{80C0A0CB-0DD5-4573-B000-C4B7C313C70D}");
// release-8.0.1
// to 8.1.0...
To<ConvertTinyMceAndGridMediaUrlsToLocalLink>("{B69B6E8C-A769-4044-A27E-4A4E18D1645A}");
To<RenameUserLoginDtoDateIndex>("{0372A42B-DECF-498D-B4D1-6379E907EB94}");
//FINAL
}

View File

@@ -1,21 +0,0 @@
using System.Linq;
using Umbraco.Core.Persistence.Dtos;
namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
{
public class AddLockTable : MigrationBase
{
public AddLockTable(IMigrationContext context)
: base(context)
{ }
public override void Migrate()
{
var tables = SqlSyntax.GetTablesInSchema(Context.Database);
if (tables.InvariantContains("umbracoLock"))
return;
Create.Table<LockDto>(true);
}
}
}

View File

@@ -1,22 +0,0 @@
using Umbraco.Core.Persistence.Dtos;
namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
{
public class AddUserLoginDtoDateIndex : MigrationBase
{
public AddUserLoginDtoDateIndex(IMigrationContext context)
: base(context)
{ }
public override void Migrate()
{
if (!IndexExists("IX_umbracoUserLogin_lastValidatedUtc"))
Create.Index("IX_umbracoUserLogin_lastValidatedUtc")
.OnTable(UserLoginDto.TableName)
.OnColumn("lastValidatedUtc")
.Ascending()
.WithOptions().NonClustered()
.Do();
}
}
}

View File

@@ -0,0 +1,21 @@
namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
{
public class FixLanguageIsoCodeLength : MigrationBase
{
public FixLanguageIsoCodeLength(IMigrationContext context)
: base(context)
{ }
public override void Migrate()
{
// there is some confusion here when upgrading from v7
// it should be 14 already but that's not always the case
Alter.Table("umbracoLanguage")
.AlterColumn("languageISOCode")
.AsString(14)
.Nullable()
.Do();
}
}
}

View File

@@ -1,23 +0,0 @@
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

@@ -0,0 +1,36 @@
using Umbraco.Core.Persistence.Dtos;
namespace Umbraco.Core.Migrations.Upgrade.V_8_1_0
{
public class RenameUserLoginDtoDateIndex : MigrationBase
{
public RenameUserLoginDtoDateIndex(IMigrationContext context)
: base(context)
{ }
public override void Migrate()
{
// there has been some confusion with an index name, resulting in
// different names depending on which migration path was followed,
// and discrepancies between an upgraded or an installed database.
// better normalize
if (IndexExists("IX_umbracoUserLogin_lastValidatedUtc"))
return;
if (IndexExists("IX_userLoginDto_lastValidatedUtc"))
Delete
.Index("IX_userLoginDto_lastValidatedUtc")
.OnTable(UserLoginDto.TableName)
.Do();
Create
.Index("IX_umbracoUserLogin_lastValidatedUtc")
.OnTable(UserLoginDto.TableName)
.OnColumn("lastValidatedUtc")
.Ascending()
.WithOptions().NonClustered()
.Do();
}
}
}

View File

@@ -37,7 +37,7 @@ namespace Umbraco.Core.Persistence.Dtos
/// </remarks>
[Column("lastValidatedUtc")]
[NullSetting(NullSetting = NullSettings.NotNull)]
[Index(IndexTypes.NonClustered, Name = "IX_userLoginDto_lastValidatedUtc")]
[Index(IndexTypes.NonClustered, Name = "IX_umbracoUserLogin_lastValidatedUtc")]
public DateTime LastValidatedUtc { get; set; }
/// <summary>

View File

@@ -222,12 +222,14 @@
<Compile Include="Migrations\Upgrade\Common\DeleteKeysAndIndexes.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\MergeDateAndDateTimePropertyEditor.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\RenameMediaVersionTable.cs" />
<Compile Include="Migrations\Upgrade\V_8_1_0\RenameUserLoginDtoDateIndex.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_1\ChangeNuCacheJsonFormat.cs" />
<Compile Include="Mapping\MapDefinitionCollection.cs" />
<Compile Include="Mapping\MapDefinitionCollectionBuilder.cs" />
<Compile Include="Mapping\IMapDefinition.cs" />
<Compile Include="Mapping\UmbracoMapper.cs" />
<Compile Include="Migrations\Upgrade\V_8_1_0\ConvertTinyMceAndGridMediaUrlsToLocalLink.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\FixLanguageIsoCodeLength.cs" />
<Compile Include="Models\CultureImpact.cs" />
<Compile Include="Models\PublishedContent\ILivePublishedModelFactory.cs" />
<Compile Include="Persistence\Dtos\PropertyTypeCommonDto.cs" />
@@ -388,7 +390,6 @@
<Compile Include="Migrations\PostMigrations\IPublishedSnapshotRebuilder.cs" />
<Compile Include="Migrations\PostMigrations\PublishedSnapshotRebuilder.cs" />
<Compile Include="Migrations\PostMigrations\RebuildPublishedSnapshot.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\AddUserLoginDtoDateIndex.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\ConvertRelatedLinksToMultiUrlPicker.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\AddContentTypeIsElementColumn.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\AddLogTableColumns.cs" />
@@ -401,7 +402,6 @@
<Compile Include="Migrations\Upgrade\V_8_0_0\DropTaskTables.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\DropTemplateDesignColumn.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\DropXmlTables.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\MakeRedirectUrlVariant.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\MakeTagsVariant.cs" />
@@ -691,7 +691,6 @@
<Compile Include="Migrations\MigrationPlan.cs" />
<Compile Include="Migrations\NoopMigration.cs" />
<Compile Include="Migrations\Upgrade\UmbracoPlan.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\AddLockTable.cs" />
<Compile Include="Migrations\Upgrade\Upgrader.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\DropMigrationsTable.cs" />
<Compile Include="Models\AuditItem.cs" />