Fix migrations
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using Umbraco.Core.Migrations.Install;
|
||||
|
||||
namespace Umbraco.Core.Migrations.Upgrade.Post
|
||||
namespace Umbraco.Core.Migrations.Upgrade.Common
|
||||
{
|
||||
public class CreateKeysAndIndexes : MigrationBase
|
||||
{
|
||||
@@ -10,8 +10,8 @@ namespace Umbraco.Core.Migrations.Upgrade.Post
|
||||
|
||||
public override void Migrate()
|
||||
{
|
||||
// really make sure there is nothing left
|
||||
Delete.KeysAndIndexes().Do();
|
||||
// remove those that may already have keys
|
||||
Delete.KeysAndIndexes(Constants.DatabaseSchema.Tables.KeyValue).Do();
|
||||
|
||||
// re-create *all* keys and indexes
|
||||
foreach (var x in DatabaseSchemaCreator.OrderedTables)
|
||||
@@ -0,0 +1,75 @@
|
||||
namespace Umbraco.Core.Migrations.Upgrade.Common
|
||||
{
|
||||
public class DeleteKeysAndIndexes : MigrationBase
|
||||
{
|
||||
public DeleteKeysAndIndexes(IMigrationContext context)
|
||||
: base(context)
|
||||
{ }
|
||||
|
||||
public override void Migrate()
|
||||
{
|
||||
// all v7.14 tables
|
||||
var tables = new[]
|
||||
{
|
||||
"cmsContent",
|
||||
"cmsContentType",
|
||||
"cmsContentType2ContentType",
|
||||
"cmsContentTypeAllowedContentType",
|
||||
"cmsContentVersion",
|
||||
"cmsContentXml",
|
||||
"cmsDataType",
|
||||
"cmsDataTypePreValues",
|
||||
"cmsDictionary",
|
||||
"cmsDocument",
|
||||
"cmsDocumentType",
|
||||
"cmsLanguageText",
|
||||
"cmsMacro",
|
||||
"cmsMacroProperty",
|
||||
"cmsMedia",
|
||||
"cmsMember",
|
||||
"cmsMember2MemberGroup",
|
||||
"cmsMemberType",
|
||||
"cmsPreviewXml",
|
||||
"cmsPropertyData",
|
||||
"cmsPropertyType",
|
||||
"cmsPropertyTypeGroup",
|
||||
"cmsTagRelationship",
|
||||
"cmsTags",
|
||||
"cmsTask",
|
||||
"cmsTaskType",
|
||||
"cmsTemplate",
|
||||
"umbracoAccess",
|
||||
"umbracoAccessRule",
|
||||
"umbracoAudit",
|
||||
"umbracoCacheInstruction",
|
||||
"umbracoConsent",
|
||||
"umbracoDomains",
|
||||
"umbracoExternalLogin",
|
||||
"umbracoLanguage",
|
||||
"umbracoLock",
|
||||
"umbracoLog",
|
||||
"umbracoMigration",
|
||||
"umbracoNode",
|
||||
"umbracoRedirectUrl",
|
||||
"umbracoRelation",
|
||||
"umbracoRelationType",
|
||||
"umbracoServer",
|
||||
"umbracoUser",
|
||||
"umbracoUser2NodeNotify",
|
||||
"umbracoUser2UserGroup",
|
||||
"umbracoUserGroup",
|
||||
"umbracoUserGroup2App",
|
||||
"umbracoUserGroup2NodePermission",
|
||||
"umbracoUserLogin",
|
||||
"umbracoUserStartNode",
|
||||
};
|
||||
|
||||
// delete *all* keys and indexes - because of FKs
|
||||
// on known v7 tables only
|
||||
foreach (var table in tables)
|
||||
Delete.KeysAndIndexes(table, false, true, false).Do();
|
||||
foreach (var table in tables)
|
||||
Delete.KeysAndIndexes(table, true, false, true).Do();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Configuration;
|
||||
using Semver;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Migrations.Upgrade.Common;
|
||||
using Umbraco.Core.Migrations.Upgrade.V_8_0_0;
|
||||
using Umbraco.Core.Migrations.Upgrade.V_8_0_1;
|
||||
using Umbraco.Core.Migrations.Upgrade.V_8_1_0;
|
||||
@@ -89,9 +90,12 @@ namespace Umbraco.Core.Migrations.Upgrade
|
||||
//
|
||||
From("{init-7.14.0}");
|
||||
|
||||
To<DeleteKeysAndIndexes>("{B36B9ABD-374E-465B-9C5F-26AB0D39326F}");
|
||||
|
||||
To<AddLockObjects>("{7C447271-CA3F-4A6A-A913-5D77015655CB}");
|
||||
To<AddContentNuTable>("{CBFF58A2-7B50-4F75-8E98-249920DB0F37}");
|
||||
To<RefactorXmlColumns>("{3D18920C-E84D-405C-A06A-B7CEE52FE5DD}");
|
||||
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}");
|
||||
To<DataTypeMigration>("{8640C9E4-A1C0-4C59-99BB-609B4E604981}");
|
||||
@@ -113,14 +117,14 @@ 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}");
|
||||
//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}");
|
||||
//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}");
|
||||
@@ -135,6 +139,8 @@ namespace Umbraco.Core.Migrations.Upgrade
|
||||
.To<RadioAndCheckboxAndDropdownPropertyEditorsMigration>("{940FD19A-00A8-4D5C-B8FF-939143585726}")
|
||||
.As("{0576E786-5C30-4000-B969-302B61E90CA3}");
|
||||
|
||||
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
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Persistence.DatabaseAnnotations;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
{
|
||||
@@ -12,31 +13,35 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
|
||||
public override void Migrate()
|
||||
{
|
||||
var tables = SqlSyntax.GetTablesInSchema(Context.Database).ToArray();
|
||||
var tables = SqlSyntax.GetTablesInSchema(Context.Database);
|
||||
if (tables.InvariantContains("cmsContentNu")) return;
|
||||
|
||||
var textType = SqlSyntax.GetSpecialDbType(SpecialDbTypes.NTEXT);
|
||||
// FIXME how can we specify the OnDelete(Rule.Cascade) on the DTO?
|
||||
// FIXME are we creating other tables? need to make sure we don't created keys and indexes? or?
|
||||
Create.Table<ContentNuDto>(true).Do();
|
||||
|
||||
Create.Table("cmsContentNu")
|
||||
.WithColumn("nodeId").AsInt32().NotNullable()
|
||||
.WithColumn("published").AsBoolean().NotNullable()
|
||||
.WithColumn("data").AsCustom(textType).NotNullable()
|
||||
.WithColumn("rv").AsInt64().NotNullable().WithDefaultValue(0)
|
||||
.Do();
|
||||
//var textType = SqlSyntax.GetSpecialDbType(SpecialDbTypes.NTEXT);
|
||||
|
||||
Create.PrimaryKey("PK_cmsContentNu")
|
||||
.OnTable("cmsContentNu")
|
||||
.Columns(new[] { "nodeId", "published" })
|
||||
.Do();
|
||||
//Create.Table("cmsContentNu")
|
||||
// .WithColumn("nodeId").AsInt32().NotNullable()
|
||||
// .WithColumn("published").AsBoolean().NotNullable()
|
||||
// .WithColumn("data").AsCustom(textType).NotNullable()
|
||||
// .WithColumn("rv").AsInt64().NotNullable().WithDefaultValue(0)
|
||||
// .Do();
|
||||
|
||||
Create.ForeignKey("FK_cmsContentNu_umbracoNode_id")
|
||||
.FromTable("cmsContentNu")
|
||||
.ForeignColumn("nodeId")
|
||||
.ToTable("umbracoNode")
|
||||
.PrimaryColumn("id")
|
||||
.OnDelete(Rule.Cascade)
|
||||
.OnUpdate(Rule.None)
|
||||
.Do();
|
||||
//Create.PrimaryKey("PK_cmsContentNu")
|
||||
// .OnTable("cmsContentNu")
|
||||
// .Columns(new[] { "nodeId", "published" })
|
||||
// .Do();
|
||||
|
||||
//Create.ForeignKey("FK_cmsContentNu_umbracoNode_id")
|
||||
// .FromTable("cmsContentNu")
|
||||
// .ForeignColumn("nodeId")
|
||||
// .ToTable("umbracoNode")
|
||||
// .PrimaryColumn("id")
|
||||
// .OnDelete(Rule.Cascade)
|
||||
// .OnUpdate(Rule.None)
|
||||
// .Do();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
{
|
||||
@@ -10,15 +11,11 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
|
||||
public override void Migrate()
|
||||
{
|
||||
var tables = SqlSyntax.GetTablesInSchema(Context.Database).ToArray();
|
||||
if (tables.InvariantContains("umbracoLock") == false)
|
||||
{
|
||||
Create.Table("umbracoLock")
|
||||
.WithColumn("id").AsInt32().PrimaryKey("PK_umbracoLock")
|
||||
.WithColumn("value").AsInt32().NotNullable()
|
||||
.WithColumn("name").AsString(64).NotNullable()
|
||||
.Do();
|
||||
}
|
||||
var tables = SqlSyntax.GetTablesInSchema(Context.Database);
|
||||
if (tables.InvariantContains("umbracoLock"))
|
||||
return;
|
||||
|
||||
Create.Table<LockDto>(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,25 +11,30 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
|
||||
public override void Migrate()
|
||||
{
|
||||
// fixme
|
||||
Create.KeysAndIndexes<LanguageDto>().Do();
|
||||
Create.KeysAndIndexes<NodeDto>().Do();
|
||||
Create.KeysAndIndexes<ContentTypeDto>().Do();
|
||||
Create.KeysAndIndexes<ContentDto>().Do();
|
||||
Create.KeysAndIndexes<ContentVersionDto>().Do();
|
||||
// fixme - ends up creating an index on a not-yet-existing column!
|
||||
// LanguageColumn migration has run but FallbackLanguage has not
|
||||
// how can we manage this?
|
||||
// a) creating and dropping all keys is ugly
|
||||
// can we stop dropping them all?
|
||||
// b) should get captures of Dto objects and use them in migrations
|
||||
|
||||
Create.Table<ContentVersionCultureVariationDto>().Do();
|
||||
Create.Table<DocumentCultureVariationDto>().Do();
|
||||
//Create.KeysAndIndexes<LanguageDto>().Do();
|
||||
//Create.KeysAndIndexes<NodeDto>().Do();
|
||||
//Create.KeysAndIndexes<ContentTypeDto>().Do();
|
||||
//Create.KeysAndIndexes<ContentDto>().Do();
|
||||
//Create.KeysAndIndexes<ContentVersionDto>().Do();
|
||||
|
||||
Delete.KeysAndIndexes(ContentVersionCultureVariationDto.TableName).Do();
|
||||
Delete.KeysAndIndexes(DocumentCultureVariationDto.TableName).Do();
|
||||
Create.Table<ContentVersionCultureVariationDto>(true).Do();
|
||||
Create.Table<DocumentCultureVariationDto>(true).Do();
|
||||
|
||||
Delete.KeysAndIndexes(LanguageDto.TableName).Do();
|
||||
Delete.KeysAndIndexes(ContentVersionDto.TableName).Do();
|
||||
Delete.KeysAndIndexes(ContentDto.TableName).Do();
|
||||
Delete.KeysAndIndexes(ContentTypeDto.TableName).Do();
|
||||
Delete.KeysAndIndexes(NodeDto.TableName).Do();
|
||||
//Delete.KeysAndIndexes(ContentVersionCultureVariationDto.TableName).Do();
|
||||
//Delete.KeysAndIndexes(DocumentCultureVariationDto.TableName).Do();
|
||||
|
||||
//Delete.KeysAndIndexes(LanguageDto.TableName).Do();
|
||||
//Delete.KeysAndIndexes(ContentVersionDto.TableName).Do();
|
||||
//Delete.KeysAndIndexes(ContentDto.TableName).Do();
|
||||
//Delete.KeysAndIndexes(ContentTypeDto.TableName).Do();
|
||||
//Delete.KeysAndIndexes(NodeDto.TableName).Do();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using NPoco;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
@@ -18,11 +19,6 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
|
||||
public override void Migrate()
|
||||
{
|
||||
// delete *all* keys and indexes - because of FKs
|
||||
Delete.KeysAndIndexes().Do();
|
||||
if (!Context.PostMigrations.Contains(typeof(Post.CreateKeysAndIndexes)))
|
||||
Context.PostMigrations.Add(typeof(Post.CreateKeysAndIndexes));
|
||||
|
||||
// drop and create columns
|
||||
Delete.Column("pk").FromTable("cmsDataType").Do();
|
||||
|
||||
@@ -69,8 +65,23 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
if (aliases.Length != group.Count() || aliases.Any(string.IsNullOrWhiteSpace))
|
||||
throw new InvalidOperationException($"Cannot migrate datatype w/ id={dataType.NodeId} preValues: duplicate or null/empty alias.");
|
||||
|
||||
// must take care of all odd situations ;-(
|
||||
object FmtPreValue(string alias, string preValue)
|
||||
{
|
||||
Current.Logger.Debug(typeof(DataTypeMigration), "DEBUG " + dataType.EditorAlias + " / " + alias);
|
||||
if (dataType.EditorAlias == "Umbraco.MediaPicker2")
|
||||
{
|
||||
if (alias == "multiPicker" ||
|
||||
alias == "onlyImages" ||
|
||||
alias == "disableFolderSelect")
|
||||
return preValue == "1";
|
||||
}
|
||||
|
||||
return preValue.DetectIsJson() ? JsonConvert.DeserializeObject(preValue) : preValue;
|
||||
}
|
||||
|
||||
// dictionary-base prevalues
|
||||
var values = group.ToDictionary(x => x.Alias, x => x.Value);
|
||||
var values = group.ToDictionary(x => x.Alias, x => FmtPreValue(x.Alias, x.Value));
|
||||
dataType.Configuration = JsonConvert.SerializeObject(values);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
public override void Migrate()
|
||||
{
|
||||
Delete.Table("umbracoMigration").Do();
|
||||
if (TableExists("umbracoMigration"))
|
||||
Delete.Table("umbracoMigration").Do();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,19 +11,6 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
public override void Migrate()
|
||||
{
|
||||
AddColumn<RedirectUrlDto>("culture");
|
||||
|
||||
Delete.Index("IX_umbracoRedirectUrl").OnTable(Constants.DatabaseSchema.Tables.RedirectUrl).Do();
|
||||
Create.Index("IX_umbracoRedirectUrl").OnTable(Constants.DatabaseSchema.Tables.RedirectUrl)
|
||||
.OnColumn("urlHash")
|
||||
.Ascending()
|
||||
.OnColumn("contentKey")
|
||||
.Ascending()
|
||||
.OnColumn("culture")
|
||||
.Ascending()
|
||||
.OnColumn("createDateUtc")
|
||||
.Ascending()
|
||||
.WithOptions().Unique()
|
||||
.Do();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,17 +11,6 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
public override void Migrate()
|
||||
{
|
||||
AddColumn<TagDto>("languageId");
|
||||
|
||||
Delete.Index($"IX_{Constants.DatabaseSchema.Tables.Tag}").OnTable(Constants.DatabaseSchema.Tables.Tag).Do();
|
||||
Create.Index($"IX_{Constants.DatabaseSchema.Tables.Tag}").OnTable(Constants.DatabaseSchema.Tables.Tag)
|
||||
.OnColumn("group")
|
||||
.Ascending()
|
||||
.OnColumn("tag")
|
||||
.Ascending()
|
||||
.OnColumn("languageId")
|
||||
.Ascending()
|
||||
.WithOptions().Unique()
|
||||
.Do();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
|
||||
namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
{
|
||||
public class RefactorXmlColumns : MigrationBase
|
||||
{
|
||||
public RefactorXmlColumns(IMigrationContext context)
|
||||
: base(context)
|
||||
{ }
|
||||
|
||||
public override void Migrate()
|
||||
{
|
||||
if (ColumnExists("cmsContentXml", "Rv") == false)
|
||||
Alter.Table("cmsContentXml").AddColumn("Rv").AsInt64().NotNullable().WithDefaultValue(0).Do();
|
||||
|
||||
if (ColumnExists("cmsPreviewXml", "Rv") == false)
|
||||
Alter.Table("cmsPreviewXml").AddColumn("Rv").AsInt64().NotNullable().WithDefaultValue(0).Do();
|
||||
|
||||
// remove the any PK_ and the FK_ to cmsContentVersion.VersionId
|
||||
var constraints = SqlSyntax.GetConstraintsPerColumn(Context.Database).Distinct().ToArray();
|
||||
var dups = new List<string>();
|
||||
foreach (var c in constraints.Where(x => x.Item1.InvariantEquals("cmsPreviewXml") && x.Item3.InvariantStartsWith("PK_")))
|
||||
{
|
||||
var keyName = c.Item3.ToLowerInvariant();
|
||||
if (dups.Contains(keyName))
|
||||
{
|
||||
Logger.Warn<RefactorXmlColumns>("Duplicate constraint '{Constraint}'", c.Item3);
|
||||
continue;
|
||||
}
|
||||
dups.Add(keyName);
|
||||
Delete.PrimaryKey(c.Item3).FromTable(c.Item1).Do();
|
||||
}
|
||||
foreach (var c in constraints.Where(x => x.Item1.InvariantEquals("cmsPreviewXml") && x.Item3.InvariantStartsWith("FK_cmsPreviewXml_cmsContentVersion")))
|
||||
{
|
||||
Delete.ForeignKey().FromTable("cmsPreviewXml").ForeignColumn("VersionId")
|
||||
.ToTable("cmsContentVersion").PrimaryColumn("VersionId")
|
||||
.Do();
|
||||
}
|
||||
|
||||
if (ColumnExists("cmsPreviewXml", "Timestamp"))
|
||||
Delete.Column("Timestamp").FromTable("cmsPreviewXml").Do();
|
||||
|
||||
if (ColumnExists("cmsPreviewXml", "VersionId"))
|
||||
{
|
||||
RemoveDuplicates();
|
||||
Delete.Column("VersionId").FromTable("cmsPreviewXml").Do();
|
||||
}
|
||||
|
||||
// re-create the primary key
|
||||
Create.PrimaryKey("PK_cmsPreviewXml")
|
||||
.OnTable("cmsPreviewXml")
|
||||
.Columns(new[] { "nodeId" })
|
||||
.Do();
|
||||
}
|
||||
|
||||
private void RemoveDuplicates()
|
||||
{
|
||||
const string sql = @"delete from cmsPreviewXml where versionId in (
|
||||
select cmsPreviewXml.versionId from cmsPreviewXml
|
||||
join cmsDocument on cmsPreviewXml.versionId=cmsDocument.versionId
|
||||
where cmsDocument.newest <> 1)";
|
||||
|
||||
Context.Database.Execute(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
{
|
||||
public class RenameMediaVersionTable : MigrationBase
|
||||
{
|
||||
public RenameMediaVersionTable(IMigrationContext context)
|
||||
: base(context)
|
||||
{ }
|
||||
|
||||
public override void Migrate()
|
||||
{
|
||||
Rename.Table("cmsMedia").To(Constants.DatabaseSchema.Tables.MediaVersion).Do();
|
||||
|
||||
// that is not supported on SqlCE
|
||||
//Rename.Column("versionId").OnTable(Constants.DatabaseSchema.Tables.MediaVersion).To("id").Do();
|
||||
|
||||
AddColumn<MediaVersionDto>("id", out var sqls);
|
||||
|
||||
// SQLCE does not support UPDATE...FROM
|
||||
var temp2 = Database.Fetch<dynamic>($@"SELECT v.versionId, v.id
|
||||
FROM cmsContentVersion v
|
||||
JOIN umbracoNode n on v.contentId=n.id
|
||||
WHERE n.nodeObjectType='{Constants.ObjectTypes.Media}'");
|
||||
foreach (var t in temp2)
|
||||
Execute.Sql($"UPDATE {Constants.DatabaseSchema.Tables.MediaVersion} SET id={t.id} WHERE versionId='{t.versionId}'").Do();
|
||||
|
||||
foreach (var sql in sqls)
|
||||
Execute.Sql(sql).Do();
|
||||
|
||||
AddColumn<MediaVersionDto>("path", out sqls);
|
||||
|
||||
Execute.Sql($"UPDATE {Constants.DatabaseSchema.Tables.MediaVersion} SET path=mediaPath").Do();
|
||||
|
||||
foreach (var sql in sqls)
|
||||
Execute.Sql(sql).Do();
|
||||
|
||||
// we had to run sqls to get the NULL constraints, but we need to get rid of most
|
||||
Delete.KeysAndIndexes(Constants.DatabaseSchema.Tables.MediaVersion).Do();
|
||||
|
||||
Delete.Column("mediaPath").FromTable(Constants.DatabaseSchema.Tables.MediaVersion).Do();
|
||||
Delete.Column("versionId").FromTable(Constants.DatabaseSchema.Tables.MediaVersion).Do();
|
||||
Delete.Column("nodeId").FromTable(Constants.DatabaseSchema.Tables.MediaVersion).Do();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,9 @@
|
||||
{
|
||||
public class RenameUmbracoDomainsTable : MigrationBase
|
||||
{
|
||||
public RenameUmbracoDomainsTable(IMigrationContext context) : base(context) { }
|
||||
public RenameUmbracoDomainsTable(IMigrationContext context)
|
||||
: base(context)
|
||||
{ }
|
||||
|
||||
public override void Migrate()
|
||||
{
|
||||
|
||||
@@ -11,20 +11,22 @@
|
||||
var exists = Database.Fetch<int>("select id from umbracoUser where id=-1;").Count > 0;
|
||||
if (exists) return;
|
||||
|
||||
Database.Execute("update umbracoUser set userLogin = userLogin + '__' where userId=0");
|
||||
Database.Execute("update umbracoUser set userLogin = userLogin + '__' where id=0");
|
||||
|
||||
Database.Execute("set identity_insert umbracoUser on;");
|
||||
Database.Execute(@"
|
||||
insert into umbracoUser select -1,
|
||||
userDisabled, userNoConsole, userName, substring(userLogin, 1, len(userLogin) - 2), userPassword, passwordConfig,
|
||||
insert into umbracoUser select
|
||||
-1 id,
|
||||
userDisabled, userNoConsole, userName, substring(userLogin, 1, len(userLogin) - 2) userLogin, userPassword, passwordConfig,
|
||||
userEmail, userLanguage, securityStampToken, failedLoginAttempts, lastLockoutDate,
|
||||
lastPasswordChangeDate, lastLoginDate, emailConfirmedDate, invitedDate,
|
||||
createDate, updateDate, avatar
|
||||
createDate, updateDate, avatar, tourData
|
||||
from umbracoUser where id=0;");
|
||||
Database.Execute("set identity_insert umbracoUser off;");
|
||||
|
||||
Database.Execute("update umbracoUser2UserGroup set userId=-1 where userId=0;");
|
||||
Database.Execute("update umbracoNode set nodeUser=-1 where nodeUser=0;");
|
||||
Database.Execute("update umbracoUserLogin set userId=-1 where userId=0;");
|
||||
Database.Execute($"update {Constants.DatabaseSchema.Tables.ContentVersion} set userId=-1 where userId=0;");
|
||||
Database.Execute("delete from umbracoUser where id=0;");
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
Delete.Column("releaseDate").FromTable("umbracoDocument").Do();
|
||||
Delete.Column("expireDate").FromTable("umbracoDocument").Do();
|
||||
//add new table
|
||||
Create.Table<ContentScheduleDto>().Do();
|
||||
Create.Table<ContentScheduleDto>(true).Do();
|
||||
|
||||
//migrate the schedule
|
||||
foreach(var s in schedules)
|
||||
|
||||
@@ -15,14 +15,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
AlterColumn<TagDto>(Constants.DatabaseSchema.Tables.Tag, "group");
|
||||
AlterColumn<TagDto>(Constants.DatabaseSchema.Tables.Tag, "tag");
|
||||
|
||||
//AddColumn<TagDto>(Constants.DatabaseSchema.Tables.Tag, "key");
|
||||
|
||||
// kill unused parentId column
|
||||
var allConstraints = Context.SqlContext.SqlSyntax.GetConstraintsPerTable(Database);
|
||||
var tableConstraints = allConstraints.Where(x => x.Item1.InvariantEquals("cmstags"));
|
||||
var exists = tableConstraints.Any(x => x.Item2 == "FK_cmsTags_cmsTags");
|
||||
if (exists)
|
||||
Delete.ForeignKey("FK_cmsTags_cmsTags").OnTable(Constants.DatabaseSchema.Tables.Tag).Do();
|
||||
Delete.Column("ParentId").FromTable(Constants.DatabaseSchema.Tables.Tag).Do();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using NPoco;
|
||||
using Umbraco.Core.Persistence.DatabaseAnnotations;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
{
|
||||
@@ -15,24 +13,19 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
|
||||
public override void Migrate()
|
||||
{
|
||||
//first allow NULL-able
|
||||
// first allow NULL-able
|
||||
Alter.Table(ContentVersionCultureVariationDto.TableName).AlterColumn("availableUserId").AsInt32().Nullable().Do();
|
||||
Alter.Table(ContentVersionDto.TableName).AlterColumn("userId").AsInt32().Nullable().Do();
|
||||
Alter.Table(Constants.DatabaseSchema.Tables.Log).AlterColumn("userId").AsInt32().Nullable().Do();
|
||||
Alter.Table(NodeDto.TableName).AlterColumn("nodeUser").AsInt32().Nullable().Do();
|
||||
|
||||
//then we can update any non existing users to NULL
|
||||
// then we can update any non existing users to NULL
|
||||
Execute.Sql($"UPDATE {ContentVersionCultureVariationDto.TableName} SET availableUserId = NULL WHERE availableUserId NOT IN (SELECT id FROM {UserDto.TableName})").Do();
|
||||
Execute.Sql($"UPDATE {ContentVersionDto.TableName} SET userId = NULL WHERE userId NOT IN (SELECT id FROM {UserDto.TableName})").Do();
|
||||
Execute.Sql($"UPDATE {Constants.DatabaseSchema.Tables.Log} SET userId = NULL WHERE userId NOT IN (SELECT id FROM {UserDto.TableName})").Do();
|
||||
Execute.Sql($"UPDATE {NodeDto.TableName} SET nodeUser = NULL WHERE nodeUser NOT IN (SELECT id FROM {UserDto.TableName})").Do();
|
||||
|
||||
//now NULL-able with FKs
|
||||
Alter.Table(ContentVersionCultureVariationDto.TableName).AlterColumn("availableUserId").AsInt32().Nullable().ForeignKey(UserDto.TableName, "id").Do();
|
||||
Alter.Table(ContentVersionDto.TableName).AlterColumn("userId").AsInt32().Nullable().ForeignKey(UserDto.TableName, "id").Do();
|
||||
Alter.Table(Constants.DatabaseSchema.Tables.Log).AlterColumn("userId").AsInt32().Nullable().ForeignKey(UserDto.TableName, "id").Do();
|
||||
Alter.Table(NodeDto.TableName).AlterColumn("nodeUser").AsInt32().Nullable().ForeignKey(UserDto.TableName, "id").Do();
|
||||
// FKs will be created after migrations
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,6 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
|
||||
|
||||
public override void Migrate()
|
||||
{
|
||||
// delete *all* keys and indexes - because of FKs
|
||||
Delete.KeysAndIndexes().Do();
|
||||
if (!Context.PostMigrations.Contains(typeof(Post.CreateKeysAndIndexes)))
|
||||
Context.PostMigrations.Add(typeof(Post.CreateKeysAndIndexes));
|
||||
|
||||
MigratePropertyData();
|
||||
MigrateContentAndPropertyTypes();
|
||||
MigrateContent();
|
||||
@@ -318,7 +313,7 @@ WHERE v1.propertyTypeId=v2.propertyTypeId AND v1.languageId=v2.languageId AND v1
|
||||
|
||||
public const string Tag = "cmsTags";
|
||||
public const string TagRelationship = "cmsTagRelationship";
|
||||
|
||||
|
||||
// ReSharper restore UnusedMember.Local
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,9 +26,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_1_0
|
||||
RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
|
||||
|
||||
var sqlPropertyData = Sql()
|
||||
.Select<PropertyDataDto>()
|
||||
.AndSelect<PropertyTypeDto>()
|
||||
.AndSelect<DataTypeDto>()
|
||||
.Select<PropertyDataDto>(r => r.Select(x => x.PropertyTypeDto, r1 => r1.Select(x => x.DataTypeDto)))
|
||||
.From<PropertyDataDto>()
|
||||
.InnerJoin<PropertyTypeDto>().On<PropertyDataDto, PropertyTypeDto>((left, right) => left.PropertyTypeId == right.Id)
|
||||
.InnerJoin<DataTypeDto>().On<PropertyTypeDto, DataTypeDto>((left, right) => left.DataTypeId == right.NodeId)
|
||||
|
||||
@@ -219,7 +219,9 @@
|
||||
<Compile Include="Composing\TypeLoader.cs" />
|
||||
<Compile Include="IO\MediaPathSchemes\UniqueMediaPathScheme.cs" />
|
||||
<Compile Include="Mapping\MapperContext.cs" />
|
||||
<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_0_1\ChangeNuCacheJsonFormat.cs" />
|
||||
<Compile Include="Mapping\MapDefinitionCollection.cs" />
|
||||
<Compile Include="Mapping\MapDefinitionCollectionBuilder.cs" />
|
||||
@@ -416,7 +418,7 @@
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\UpdateDefaultMandatoryLanguage.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\UpdatePickerIntegerValuesToUdi.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\UserForeignKeys.cs" />
|
||||
<Compile Include="Migrations\Upgrade\Post\CreateKeysAndIndexes.cs" />
|
||||
<Compile Include="Migrations\Upgrade\Common\CreateKeysAndIndexes.cs" />
|
||||
<Compile Include="Models\AuditEntry.cs" />
|
||||
<Compile Include="Models\Consent.cs" />
|
||||
<Compile Include="Models\ConsentExtensions.cs" />
|
||||
@@ -1124,7 +1126,6 @@
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\AddContentNuTable.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\AddLockObjects.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\VariantsMigration.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\RefactorXmlColumns.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\ContentVariationMigration.cs" />
|
||||
<Compile Include="Persistence\NPocoDatabaseExtensions-Bulk.cs" />
|
||||
<Compile Include="Persistence\NPocoDatabaseExtensions.cs" />
|
||||
|
||||
Reference in New Issue
Block a user