From 2c436d5ae073ae5feff0624e6f7acd21008f388d Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Tue, 16 Apr 2019 09:39:54 +0200 Subject: [PATCH 01/82] Apply nicer log message wrapping --- .../src/views/logviewer/search.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/logviewer/search.html b/src/Umbraco.Web.UI.Client/src/views/logviewer/search.html index 5981b41598..7a7ea7699c 100644 --- a/src/Umbraco.Web.UI.Client/src/views/logviewer/search.html +++ b/src/Umbraco.Web.UI.Client/src/views/logviewer/search.html @@ -107,15 +107,15 @@ Total Items: {{ vm.logItems.totalItems }} - +
- - - + + @@ -124,7 +124,7 @@ - + From adc7201e862ddac48ea6f64c1b725f477d38074e Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Mon, 29 Apr 2019 08:24:34 +0200 Subject: [PATCH 02/82] Allow localizing content types and properties using language files --- .../Services/LocalizedTextServiceExtensions.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Core/Services/LocalizedTextServiceExtensions.cs b/src/Umbraco.Core/Services/LocalizedTextServiceExtensions.cs index 51fdb7e8e3..ce5b3ef8c4 100644 --- a/src/Umbraco.Core/Services/LocalizedTextServiceExtensions.cs +++ b/src/Umbraco.Core/Services/LocalizedTextServiceExtensions.cs @@ -83,10 +83,10 @@ namespace Umbraco.Core.Services internal static string UmbracoDictionaryTranslate(this ILocalizedTextService manager, string text) { var cultureDictionary = CultureDictionary; - return UmbracoDictionaryTranslate(text, cultureDictionary); + return manager.UmbracoDictionaryTranslate(text, cultureDictionary); } - private static string UmbracoDictionaryTranslate(string text, ICultureDictionary cultureDictionary) + private static string UmbracoDictionaryTranslate(this ILocalizedTextService manager, string text, ICultureDictionary cultureDictionary) { if (text == null) return null; @@ -95,7 +95,14 @@ namespace Umbraco.Core.Services return text; text = text.Substring(1); - return cultureDictionary[text].IfNullOrWhiteSpace(text); + var value = cultureDictionary[text]; + if (value.IsNullOrWhiteSpace() == false) + { + return value; + } + + value = manager.Localize(text.Replace('_', '/')); + return value.StartsWith("[") ? text : value; } private static ICultureDictionary CultureDictionary From fe7b114083a5203fae0440b704ecc35f55d62260 Mon Sep 17 00:00:00 2001 From: matthew-hair Date: Tue, 19 Feb 2019 19:09:11 -0600 Subject: [PATCH 03/82] fix for umbracoUserLogin not pruned Signed-off-by: matthew-hair --- src/Umbraco.Core/Persistence/Repositories/UserRepository.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Repositories/UserRepository.cs b/src/Umbraco.Core/Persistence/Repositories/UserRepository.cs index adb6389f94..e3a59d9f3f 100644 --- a/src/Umbraco.Core/Persistence/Repositories/UserRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/UserRepository.cs @@ -267,8 +267,8 @@ ORDER BY colName"; var fromDate = DateTime.UtcNow - timespan; - var count = Database.ExecuteScalar("SELECT COUNT(*) FROM umbracoUserLogin WHERE lastValidatedUtc=@fromDate", new { fromDate = fromDate }); - Database.Execute("DELETE FROM umbracoUserLogin WHERE lastValidatedUtc=@fromDate", new { fromDate = fromDate }); + var count = Database.ExecuteScalar("SELECT COUNT(*) FROM umbracoUserLogin WHERE lastValidatedUtc=<@fromDate", new { fromDate = fromDate }); + Database.Execute("DELETE FROM umbracoUserLogin WHERE lastValidatedUtc=<@fromDate", new { fromDate = fromDate }); return count; } From 5cef71e4e6bf09db9b3c2f917e44b56b9b5d5208 Mon Sep 17 00:00:00 2001 From: matthew-hair Date: Mon, 11 Mar 2019 09:50:47 -0500 Subject: [PATCH 04/82] fixed typos in ClearLoginSessions queries --- src/Umbraco.Core/Persistence/Repositories/UserRepository.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Core/Persistence/Repositories/UserRepository.cs b/src/Umbraco.Core/Persistence/Repositories/UserRepository.cs index e3a59d9f3f..9c9f89614c 100644 --- a/src/Umbraco.Core/Persistence/Repositories/UserRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/UserRepository.cs @@ -267,8 +267,8 @@ ORDER BY colName"; var fromDate = DateTime.UtcNow - timespan; - var count = Database.ExecuteScalar("SELECT COUNT(*) FROM umbracoUserLogin WHERE lastValidatedUtc=<@fromDate", new { fromDate = fromDate }); - Database.Execute("DELETE FROM umbracoUserLogin WHERE lastValidatedUtc=<@fromDate", new { fromDate = fromDate }); + var count = Database.ExecuteScalar("SELECT COUNT(*) FROM umbracoUserLogin WHERE lastValidatedUtc<=@fromDate", new { fromDate = fromDate }); + Database.Execute("DELETE FROM umbracoUserLogin WHERE lastValidatedUtc<=@fromDate", new { fromDate = fromDate }); return count; } From 3d86b08e31fdd453fc0180266eab859fbb7713db Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Tue, 23 Apr 2019 21:11:34 +0200 Subject: [PATCH 05/82] Send delete notifications when content is moved to trash --- src/Umbraco.Web/Strategies/NotificationsHandler.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web/Strategies/NotificationsHandler.cs b/src/Umbraco.Web/Strategies/NotificationsHandler.cs index d65f3c6e26..9a1e4fc959 100644 --- a/src/Umbraco.Web/Strategies/NotificationsHandler.cs +++ b/src/Umbraco.Web/Strategies/NotificationsHandler.cs @@ -59,12 +59,10 @@ namespace Umbraco.Web.Strategies applicationContext.Services.NotificationService.SendNotification(updatedEntities, ActionUpdate.Instance, applicationContext); }; - //Send notifications for the delete action - ContentService.Deleted += (sender, args) => - args.DeletedEntities.ForEach( - content => - applicationContext.Services.NotificationService.SendNotification( - content, ActionDelete.Instance, applicationContext)); + //Send notifications for the delete (send to recycle bin) action + ContentService.Trashed += (sender, args) => applicationContext.Services.NotificationService.SendNotification( + args.MoveInfoCollection.Select(mi => mi.Entity), ActionDelete.Instance, applicationContext + ); //Send notifications for the unpublish action ContentService.UnPublished += (sender, args) => From 2bdbd86787ca2bcf3b3168d4129cb13576c7d4f8 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Wed, 1 May 2019 09:10:09 +0200 Subject: [PATCH 06/82] Default nested content item names to the content type name if there are multiple content item types to choose from --- .../nestedcontent/nestedcontent.controller.js | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js index a78abf2466..d204d7589a 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js @@ -190,30 +190,45 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.NestedContent.Prop $scope.getName = function (idx) { - var name = "Item " + (idx + 1); + var name = ""; if ($scope.model.value[idx]) { var contentType = $scope.getContentTypeConfig($scope.model.value[idx].ncContentTypeAlias); - if (contentType != null && contentType.nameExp) { - // Run the expression against the stored dictionary value, NOT the node object - var item = $scope.model.value[idx]; + if (contentType != null) { + // first try getting a name using the configured label template + if (contentType.nameExp) { + // Run the expression against the stored dictionary value, NOT the node object + var item = $scope.model.value[idx]; - // Add a temporary index property - item["$index"] = (idx + 1); + // Add a temporary index property + item["$index"] = (idx + 1); - var newName = contentType.nameExp(item); - if (newName && (newName = $.trim(newName))) { - name = newName; + var newName = contentType.nameExp(item); + if (newName && (newName = $.trim(newName))) { + name = newName; + } + + // Delete the index property as we don't want to persist it + delete item["$index"]; } - // Delete the index property as we don't want to persist it - delete item["$index"]; + // if we still do not have a name and we have multiple content types to choose from, use the content type name (same as is shown in the content type picker) + if (!name && $scope.scaffolds.length > 1) { + var scaffold = $scope.getScaffold(contentType.ncAlias); + if (scaffold) { + name = scaffold.contentTypeName; + } + } } } + if (!name) { + name = "Item " + (idx + 1); + } + // Update the nodes actual name value if ($scope.nodes[idx].name !== name) { $scope.nodes[idx].name = name; From 4fa07389dd926457341f627c7f7117631efb4490 Mon Sep 17 00:00:00 2001 From: Poornima Nayar Date: Fri, 3 May 2019 13:07:05 +0100 Subject: [PATCH 07/82] Search shadow-layer should be on top of the user-dialog --- .../src/less/components/application/umb-backdrop.less | 2 +- .../src/less/components/application/umb-search.less | 2 +- src/Umbraco.Web.UI.Client/src/less/variables.less | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/less/components/application/umb-backdrop.less b/src/Umbraco.Web.UI.Client/src/less/components/application/umb-backdrop.less index 1d9aaabd44..18e331756e 100644 --- a/src/Umbraco.Web.UI.Client/src/less/components/application/umb-backdrop.less +++ b/src/Umbraco.Web.UI.Client/src/less/components/application/umb-backdrop.less @@ -2,7 +2,7 @@ height: 100%; width: 100%; position: fixed; - z-index: @zindexOverlayBackdrop; + z-index: @zindexUmbOverlay; top: 0; left: 0; pointer-events: none; diff --git a/src/Umbraco.Web.UI.Client/src/less/components/application/umb-search.less b/src/Umbraco.Web.UI.Client/src/less/components/application/umb-search.less index a8fc9c7f8e..70e4f3d372 100644 --- a/src/Umbraco.Web.UI.Client/src/less/components/application/umb-search.less +++ b/src/Umbraco.Web.UI.Client/src/less/components/application/umb-search.less @@ -4,7 +4,7 @@ */ .umb-search { position: fixed; - z-index: @zindexUmbOverlay; + z-index: @zindexSearchBox; width: 660px; max-width: 90%; transform: translate(-50%, 0); diff --git a/src/Umbraco.Web.UI.Client/src/less/variables.less b/src/Umbraco.Web.UI.Client/src/less/variables.less index cc9dced7df..a1dc0ba187 100644 --- a/src/Umbraco.Web.UI.Client/src/less/variables.less +++ b/src/Umbraco.Web.UI.Client/src/less/variables.less @@ -426,7 +426,7 @@ @zindexFixedNavbar: 1030; @zindexModalBackdrop: 1040; @zindexModal: 1050; - +@zindexSearchBox: 8000; @zindexUmbOverlay: 7500; @zindexOverlayBackdrop: 2000; From 8344372ae2242cad919f71c56c36152aa8dc6a7e Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Sun, 5 May 2019 18:40:10 +0200 Subject: [PATCH 08/82] Fix the empty state for User search --- .../src/views/users/views/users/users.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/users/views/users/users.html b/src/Umbraco.Web.UI.Client/src/views/users/views/users/users.html index 24f504be63..4cab09da60 100644 --- a/src/Umbraco.Web.UI.Client/src/views/users/views/users/users.html +++ b/src/Umbraco.Web.UI.Client/src/views/users/views/users/users.html @@ -173,7 +173,7 @@ From 03006d7698885bf2124f8d44d4effc9c6f3dee0a Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Sun, 5 May 2019 19:00:36 +0200 Subject: [PATCH 09/82] Add empty state to groups search result --- .../src/views/users/views/groups/groups.controller.js | 11 ++++++++++- .../src/views/users/views/groups/groups.html | 9 +++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/users/views/groups/groups.controller.js b/src/Umbraco.Web.UI.Client/src/views/users/views/groups/groups.controller.js index ccc18ac4f0..35b6ef62b4 100644 --- a/src/Umbraco.Web.UI.Client/src/views/users/views/groups/groups.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/users/views/groups/groups.controller.js @@ -1,7 +1,7 @@ (function () { "use strict"; - function UserGroupsController($scope, $timeout, $location, userService, userGroupsResource, + function UserGroupsController($scope, $timeout, $location, $filter, userService, userGroupsResource, formHelper, localizationService, listViewHelper) { var vm = this; @@ -31,6 +31,7 @@ ug.hasAccess = user.userGroups.indexOf(ug.alias) !== -1 || user.userGroups.indexOf("admin") !== -1; return ug; }); + vm.filteredUserGroups = vm.userGroups; vm.loading = false; }); @@ -118,6 +119,14 @@ vm.selection = []; } + var unbindFilterWatcher = $scope.$watch("vm.filter", function (newVal, oldVal) { + vm.filteredUserGroups = $filter('filter')(vm.userGroups, vm.filter); + }); + + $scope.$on("$destroy", function () { + unbindFilterWatcher(); + }); + onInit(); } diff --git a/src/Umbraco.Web.UI.Client/src/views/users/views/groups/groups.html b/src/Umbraco.Web.UI.Client/src/views/users/views/groups/groups.html index ba1d6bc9eb..5d1496d90f 100644 --- a/src/Umbraco.Web.UI.Client/src/views/users/views/groups/groups.html +++ b/src/Umbraco.Web.UI.Client/src/views/users/views/groups/groups.html @@ -70,7 +70,7 @@ -
+
@@ -84,7 +84,7 @@
@@ -119,4 +119,9 @@
+ + + + +
From 60a3cdc5abfb9e1bc24746480485479c80baaed0 Mon Sep 17 00:00:00 2001 From: Thomas Pralong Date: Mon, 6 May 2019 10:47:33 +0200 Subject: [PATCH 10/82] Fix bug with multi url picker. Would display the wrong language tree in the link picker dialog --- .../infiniteeditors/linkpicker/linkpicker.controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/linkpicker/linkpicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/linkpicker/linkpicker.controller.js index 77360640cd..58f632d312 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/linkpicker/linkpicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/linkpicker/linkpicker.controller.js @@ -81,7 +81,7 @@ angular.module("umbraco").controller("Umbraco.Editors.LinkPickerController", contentResource.getById(id, options).then(function (resp) { $scope.anchorValues = tinyMceService.getAnchorNames(JSON.stringify(resp.properties)); - $scope.model.target.url = resp.urls[0].text; + $scope.model.target.url = resp.urls.filter(item => item.culture === $scope.currentNode.metaData.culture)[0].text; }); } } else if ($scope.model.target.url.length) { @@ -135,7 +135,7 @@ angular.module("umbraco").controller("Umbraco.Editors.LinkPickerController", contentResource.getById(args.node.id, options).then(function (resp) { $scope.anchorValues = tinyMceService.getAnchorNames(JSON.stringify(resp.properties)); - $scope.model.target.url = resp.urls[0].text; + $scope.model.target.url = resp.urls.filter(item => item.culture === $scope.currentNode.metaData.culture)[0].text; }); } From e091987f0f953fef49ec57e344800486ccc273d0 Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Tue, 7 May 2019 11:57:35 +0100 Subject: [PATCH 11/82] Added hash to user profile href and reordered attributes --- .../src/views/components/application/umb-app-header.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/components/application/umb-app-header.html b/src/Umbraco.Web.UI.Client/src/views/components/application/umb-app-header.html index 07d25e7465..6a190e4d39 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/application/umb-app-header.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/application/umb-app-header.html @@ -20,7 +20,7 @@
  • - + Date: Mon, 6 May 2019 18:20:38 +0200 Subject: [PATCH 12/82] Cleanup migration plan, supports 7.14.0 --- src/Umbraco.Core/Migrations/MigrationPlan.cs | 10 +- .../Migrations/Upgrade/UmbracoPlan.cs | 105 ++---- .../Upgrade/V_7_10_0/RenamePreviewFolder.cs | 36 -- .../AddRelationTypeForMediaFolderOnDelete.cs | 33 -- .../IncreaseLanguageIsoCodeColumnLength.cs | 46 --- .../Upgrade/V_7_12_0/RenameTrueFalseField.cs | 19 - .../V_7_12_0/SetDefaultTagsStorageType.cs | 51 --- .../Upgrade/V_7_12_0/UpdateUmbracoConsent.cs | 15 - .../V_7_14_0/UpdateMemberGroupPickerData.cs | 29 -- .../Upgrade/V_7_5_0/AddRedirectUrlTable.cs | 50 --- .../RemoveStylesheetDataAndTablesAgain.cs | 40 -- .../UpdateUniqueIndexOnPropertyData.cs | 44 --- .../V_7_5_5/UpdateAllowedMediaTypesAtRoot.cs | 17 - .../V_7_6_0/AddIndexToCmsMemberLoginName.cs | 41 -- .../V_7_6_0/AddIndexToUmbracoNodePath.cs | 28 -- .../V_7_6_0/AddIndexToUser2NodePermission.cs | 28 -- .../AddIndexesToUmbracoRelationTables.cs | 85 ----- .../Upgrade/V_7_6_0/AddLockObjects.cs | 27 -- .../Upgrade/V_7_6_0/AddLockTable.cs | 24 -- .../Upgrade/V_7_6_0/AddMacroUniqueIdColumn.cs | 68 ---- .../V_7_6_0/AddRelationTypeUniqueIdColumn.cs | 40 -- .../Upgrade/V_7_6_0/NormalizeTemplateGuids.cs | 37 -- .../V_7_6_0/ReduceLoginNameColumnsSize.cs | 41 -- .../V_7_6_0/RemovePropertyDataIdIndex.cs | 29 -- .../V_7_6_0/RemoveUmbracoDeployTables.cs | 30 -- .../V_7_7_0/AddIndexToDictionaryKeyColumn.cs | 38 -- .../Upgrade/V_7_7_0/AddUserGroupTables.cs | 357 ------------------ .../Upgrade/V_7_7_0/AddUserStartNodeTable.cs | 41 -- .../EnsureContentTemplatePermissions.cs | 37 -- .../V_7_7_0/ReduceDictionaryKeyColumnsSize.cs | 37 -- .../Upgrade/V_7_7_0/UpdateUserTables.cs | 48 --- .../AddIndexToPropertyTypeAliasColumn.cs | 27 -- .../V_7_8_0/AddInstructionCountColumn.cs | 20 - .../Upgrade/V_7_8_0/AddMediaVersionTable.cs | 65 ---- .../Upgrade/V_7_8_0/AddTourDataUserColumn.cs | 21 -- .../Upgrade/V_7_8_0/AddUserLoginTable.cs | 22 -- .../V_7_9_0/AddIsSensitiveMemberTypeColumn.cs | 20 - .../Upgrade/V_7_9_0/AddUmbracoAuditTable.cs | 22 -- .../Upgrade/V_7_9_0/AddUmbracoConsentTable.cs | 22 -- .../V_7_9_0/CreateSensitiveDataUserGroup.cs | 27 -- .../V_8_1_0/ChangeNuCacheJsonFormat.cs | 16 - src/Umbraco.Core/Umbraco.Core.csproj | 38 -- 42 files changed, 42 insertions(+), 1789 deletions(-) delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_10_0/RenamePreviewFolder.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/AddRelationTypeForMediaFolderOnDelete.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/IncreaseLanguageIsoCodeColumnLength.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/RenameTrueFalseField.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/SetDefaultTagsStorageType.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/UpdateUmbracoConsent.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_14_0/UpdateMemberGroupPickerData.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_5_0/AddRedirectUrlTable.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_5_0/RemoveStylesheetDataAndTablesAgain.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_5_0/UpdateUniqueIndexOnPropertyData.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_5_5/UpdateAllowedMediaTypesAtRoot.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexToCmsMemberLoginName.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexToUmbracoNodePath.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexToUser2NodePermission.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexesToUmbracoRelationTables.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddLockObjects.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddLockTable.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddMacroUniqueIdColumn.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddRelationTypeUniqueIdColumn.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/NormalizeTemplateGuids.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/ReduceLoginNameColumnsSize.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/RemovePropertyDataIdIndex.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/RemoveUmbracoDeployTables.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddIndexToDictionaryKeyColumn.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddUserGroupTables.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddUserStartNodeTable.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/EnsureContentTemplatePermissions.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/ReduceDictionaryKeyColumnsSize.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/UpdateUserTables.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddIndexToPropertyTypeAliasColumn.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddInstructionCountColumn.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddMediaVersionTable.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddTourDataUserColumn.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddUserLoginTable.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_9_0/AddIsSensitiveMemberTypeColumn.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_9_0/AddUmbracoAuditTable.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_9_0/AddUmbracoConsentTable.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_7_9_0/CreateSensitiveDataUserGroup.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_8_1_0/ChangeNuCacheJsonFormat.cs diff --git a/src/Umbraco.Core/Migrations/MigrationPlan.cs b/src/Umbraco.Core/Migrations/MigrationPlan.cs index 4be4ae7d30..321bfac34b 100644 --- a/src/Umbraco.Core/Migrations/MigrationPlan.cs +++ b/src/Umbraco.Core/Migrations/MigrationPlan.cs @@ -264,6 +264,14 @@ namespace Umbraco.Core.Migrations _finalState = finalState; } + /// + /// Throws an exception when the initial state is unknown. + /// + protected virtual void ThrowOnUnknownInitialState(string state) + { + throw new Exception($"Unknown state \"{state}\"."); + } + /// /// Executes the plan. /// @@ -287,7 +295,7 @@ namespace Umbraco.Core.Migrations logger.Info("At {OrigState}", string.IsNullOrWhiteSpace(origState) ? "origin": origState); if (!_transitions.TryGetValue(origState, out var transition)) - throw new Exception($"Unknown state \"{origState}\"."); + ThrowOnUnknownInitialState(origState); var context = new MigrationContext(scope.Database, logger); context.PostMigrations.AddRange(_postMigrationTypes); diff --git a/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs b/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs index cf06a16d31..ac0f355447 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs @@ -2,8 +2,6 @@ using System.Configuration; using Semver; using Umbraco.Core.Configuration; -using Umbraco.Core.Migrations.Upgrade.V_7_12_0; -using Umbraco.Core.Migrations.Upgrade.V_7_14_0; 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; @@ -41,23 +39,33 @@ namespace Umbraco.Core.Migrations.Upgrade if (!SemVersion.TryParse(ConfigurationManager.AppSettings[Constants.AppSettings.ConfigurationStatus], out var currentVersion)) throw new InvalidOperationException($"Could not get current version from web.config {Constants.AppSettings.ConfigurationStatus} appSetting."); - // we currently support upgrading from 7.10.0 and later - if (currentVersion < new SemVersion(7, 10)) - throw new InvalidOperationException($"Version {currentVersion} cannot be migrated to {UmbracoVersion.SemanticVersion}."); - // cannot go back in time if (currentVersion > UmbracoVersion.SemanticVersion) throw new InvalidOperationException($"Version {currentVersion} cannot be downgraded to {UmbracoVersion.SemanticVersion}."); - // upgrading from version 7 => initial state is eg "{init-7.10.0}" - // anything else is not supported - ie if 8 and above, we should have an initial state already - if (currentVersion.Major != 7) - throw new InvalidOperationException($"Version {currentVersion} is not supported by the migration plan."); + // only from 7.14.0 and above + var minVersion = new SemVersion(7, 14); + if (currentVersion < minVersion) + throw new InvalidOperationException($"Version {currentVersion} cannot be migrated to {UmbracoVersion.SemanticVersion}." + + $" Please upgrade first to at least {minVersion}."); + // initial state is eg "{init-7.14.0}" return "{init-" + currentVersion + "}"; } } + protected override void ThrowOnUnknownInitialState(string state) + { + if (state.StartsWith("{init-") && state.EndsWith("}")) + { + var initVersion = state.TrimStart("{init-").TrimEnd("}"); + throw new InvalidOperationException($"Version {UmbracoVersion.SemanticVersion} does not support migrating from {initVersion}." + + $" Please verify which versions support migrating from {initVersion}."); + } + + base.ThrowOnUnknownInitialState(state); + } + // define the plan protected void DefinePlan() { @@ -70,18 +78,17 @@ namespace Umbraco.Core.Migrations.Upgrade // // If the new migration causes a merge conflict, because someone else also added another // new migration, you NEED to fix the conflict by providing one default path, and paths - // out of the conflict states (see example below). + // out of the conflict states (see examples below). // // * Porting from version 7: // Append the ported migration to the main chain, using a new guid (same as above). - // Create a new special chain from the {init-...} state to the main chain (see example - // below). + // Create a new special chain from the {init-...} state to the main chain. - // plan starts at 7.10.0 (anything before 7.10.0 is not supported) - // upgrades from 7 to 8, and then takes care of all eventual upgrades + // plan starts at 7.14.0 (anything before 7.14.0 is not supported) // - From("{init-7.10.0}"); + From("{init-7.14.0}"); + To("{7C447271-CA3F-4A6A-A913-5D77015655CB}"); To("{CBFF58A2-7B50-4F75-8E98-249920DB0F37}"); To("{3D18920C-E84D-405C-A06A-B7CEE52FE5DD}"); @@ -95,24 +102,16 @@ namespace Umbraco.Core.Migrations.Upgrade ToWithReplace("{941B2ABA-2D06-4E04-81F5-74224F1DB037}", "{76DF5CD7-A884-41A5-8DC6-7860D95B1DF5}"); // kill AddVariationTable1 To("{A7540C58-171D-462A-91C5-7A9AA5CB8BFD}"); - Merge().To("{3E44F712-E2E3-473A-AE49-5D7F8E67CE3F}") // shannon added that one - .With().To("{65D6B71C-BDD5-4A2E-8D35-8896325E9151}") // stephan added that one + Merge() + .To("{3E44F712-E2E3-473A-AE49-5D7F8E67CE3F}") + .With() + .To("{65D6B71C-BDD5-4A2E-8D35-8896325E9151}") .As("{4CACE351-C6B9-4F0C-A6BA-85A02BBD39E4}"); To("{1350617A-4930-4D61-852F-E3AA9E692173}"); - To("{39E5B1F7-A50B-437E-B768-1723AEC45B65}"); // from 7.12.0 - - Merge() - .To("{0541A62B-EF87-4CA2-8225-F0EB98ECCC9F}") // from 7.12.0 - .To("{EB34B5DC-BB87-4005-985E-D983EA496C38}") // from 7.12.0 - .To("{517CE9EA-36D7-472A-BF4B-A0D6FB1B8F89}") // from 7.12.0 - .To("{BBD99901-1545-40E4-8A5A-D7A675C7D2F2}") // from 7.12.0 - .With() - .To("{CF51B39B-9B9A-4740-BB7C-EAF606A7BFBF}") // andy added that one - .As("{8B14CEBD-EE47-4AAD-A841-93551D917F11}"); - - ToWithReplace("{2C87AA47-D1BC-4ECB-8A73-2D8D1046C27F}", "{5F4597F4-A4E0-4AFE-90B5-6D2F896830EB}"); // merge - ToWithReplace("{B19BF0F2-E1C6-4AEB-A146-BC559D97A2C6}", "{290C18EE-B3DE-4769-84F1-1F467F3F76DA}"); // merge + To("{CF51B39B-9B9A-4740-BB7C-EAF606A7BFBF}"); + To("{5F4597F4-A4E0-4AFE-90B5-6D2F896830EB}"); + To("{290C18EE-B3DE-4769-84F1-1F467F3F76DA}"); To("{6A2C7C1B-A9DB-4EA9-B6AB-78E7D5B722A7}"); To("{77874C77-93E5-4488-A404-A630907CEEF0}"); To("{8804D8E8-FE62-4E3A-B8A2-C047C2118C38}"); @@ -121,11 +120,10 @@ namespace Umbraco.Core.Migrations.Upgrade To("{EE429F1B-9B26-43CA-89F8-A86017C809A3}"); To("{08919C4B-B431-449C-90EC-2B8445B5C6B1}"); To("{7EB0254C-CB8B-4C75-B15B-D48C55B449EB}"); - To("{648A2D5F-7467-48F8-B309-E99CEEE00E2A}"); // fixed version + To("{648A2D5F-7467-48F8-B309-E99CEEE00E2A}"); To("{C39BF2A7-1454-4047-BBFE-89E40F66ED63}"); To("{64EBCE53-E1F0-463A-B40B-E98EFCCA8AE2}"); To("{0009109C-A0B8-4F3F-8FEB-C137BBDDA268}"); - To("{8A027815-D5CD-4872-8B88-9A51AB5986A6}"); // from 7.14.0 To("{ED28B66A-E248-4D94-8CDB-9BDF574023F0}"); To("{38C809D5-6C34-426B-9BEA-EFD39162595C}"); To("{6017F044-8E70-4E10-B2A3-336949692ADD}"); @@ -138,48 +136,11 @@ namespace Umbraco.Core.Migrations.Upgrade .As("{0576E786-5C30-4000-B969-302B61E90CA3}"); To("{E0CBE54D-A84F-4A8F-9B13-900945FD7ED9}"); - To("{78BAF571-90D0-4D28-8175-EF96316DA789}"); - To("{80C0A0CB-0DD5-4573-B000-C4B7C313C70D}"); + To("{78BAF571-90D0-4D28-8175-EF96316DA789}"); // release-8.0.0 + To("{80C0A0CB-0DD5-4573-B000-C4B7C313C70D}"); // release-8.0.1 To("{B69B6E8C-A769-4044-A27E-4A4E18D1645A}"); //FINAL - - - - - // and then, need to support upgrading from more recent 7.x - // - From("{init-7.10.1}").To("{init-7.10.0}"); // same as 7.10.0 - From("{init-7.10.2}").To("{init-7.10.0}"); // same as 7.10.0 - From("{init-7.10.3}").To("{init-7.10.0}"); // same as 7.10.0 - From("{init-7.10.4}").To("{init-7.10.0}"); // same as 7.10.0 - From("{init-7.10.5}").To("{init-7.10.0}"); // same as 7.10.0 - From("{init-7.11.0}").To("{init-7.10.0}"); // same as 7.10.0 - From("{init-7.11.1}").To("{init-7.10.0}"); // same as 7.10.0 - From("{init-7.11.2}").To("{init-7.10.0}"); // same as 7.10.0 - - // 7.12.0 has migrations, define a custom chain which copies the chain - // going from {init-7.10.0} to former final (1350617A) , and then goes straight to - // main chain, skipping the migrations - // - From("{init-7.12.0}"); - // clone start / clone stop / target - ToWithClone("{init-7.10.0}", "{1350617A-4930-4D61-852F-E3AA9E692173}", "{BBD99901-1545-40E4-8A5A-D7A675C7D2F2}"); - - From("{init-7.12.1}").To("{init-7.10.0}"); // same as 7.12.0 - From("{init-7.12.2}").To("{init-7.10.0}"); // same as 7.12.0 - From("{init-7.12.3}").To("{init-7.10.0}"); // same as 7.12.0 - From("{init-7.12.4}").To("{init-7.10.0}"); // same as 7.12.0 - From("{init-7.13.0}").To("{init-7.10.0}"); // same as 7.12.0 - From("{init-7.13.1}").To("{init-7.10.0}"); // same as 7.12.0 - - // 7.14.0 has migrations, handle it... - // clone going from 7.10 to 1350617A (the last one before we started to merge 7.12 migrations), then - // clone going from CF51B39B (after 7.12 migrations) to 0009109C (the last one before we started to merge 7.12 migrations), - // ending in 8A027815 (after 7.14 migrations) - From("{init-7.14.0}") - .ToWithClone("{init-7.10.0}", "{1350617A-4930-4D61-852F-E3AA9E692173}", "{9109B8AF-6B34-46EE-9484-7434196D0C79}") - .ToWithClone("{CF51B39B-9B9A-4740-BB7C-EAF606A7BFBF}", "{0009109C-A0B8-4F3F-8FEB-C137BBDDA268}", "{8A027815-D5CD-4872-8B88-9A51AB5986A6}"); } } } diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_10_0/RenamePreviewFolder.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_10_0/RenamePreviewFolder.cs deleted file mode 100644 index 48e6d0085d..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_10_0/RenamePreviewFolder.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.IO; -using Umbraco.Core.IO; -using File = System.IO.File; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_10_0 -{ - /// - /// Renames the preview folder containing static HTML files to ensure it does not interfere with the MVC route - /// that is now supposed to render these views dynamically. We don't want to delete as people may have made - /// customizations to these files that would need to be migrated to the new .cshtml view files. - /// - public class RenamePreviewFolder : MigrationBase - { - public RenamePreviewFolder(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var previewFolderPath = IOHelper.MapPath(SystemDirectories.Umbraco + "/preview"); - if (Directory.Exists(previewFolderPath)) - { - var newPath = previewFolderPath.Replace("preview", "preview.old"); - if (Directory.Exists(newPath) == false) - { - Directory.Move(previewFolderPath, newPath); - var readmeText = - $"Static HTML files used for preview and canvas editing functionality no longer live in this directory.\r\n" + - $"Instead they have been recreated as MVC views and can now be found in '~/Umbraco/Views/Preview'.\r\n" + - $"See issue: http://issues.umbraco.org/issue/U4-11090"; - File.WriteAllText(Path.Combine(newPath, "readme.txt"), readmeText); - } - } - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/AddRelationTypeForMediaFolderOnDelete.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/AddRelationTypeForMediaFolderOnDelete.cs deleted file mode 100644 index f34ed9fb68..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/AddRelationTypeForMediaFolderOnDelete.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Umbraco.Core.Persistence.Dtos; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_12_0 -{ - public class AddRelationTypeForMediaFolderOnDelete : MigrationBase - { - - public AddRelationTypeForMediaFolderOnDelete(IMigrationContext context) : base(context) - { - } - - public override void Migrate() - { - var relationTypeCount = Context.Database.ExecuteScalar("SELECT COUNT(*) FROM umbracoRelationType WHERE alias=@alias", - new { alias = Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteAlias }); - - if (relationTypeCount > 0) - return; - - var uniqueId = (Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteAlias + "____" + Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteName).ToGuid(); - Insert.IntoTable("umbracoRelationType").Row(new - { - typeUniqueId = uniqueId, - alias = Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteAlias, - name = Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteName, - childObjectType = Constants.ObjectTypes.MediaType, - parentObjectType = Constants.ObjectTypes.MediaType, - dual = false - }).Do(); - } - - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/IncreaseLanguageIsoCodeColumnLength.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/IncreaseLanguageIsoCodeColumnLength.cs deleted file mode 100644 index fc7a21f4fa..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/IncreaseLanguageIsoCodeColumnLength.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Linq; -using Umbraco.Core.Persistence.DatabaseModelDefinitions; -using Umbraco.Core.Persistence.SqlSyntax; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_12_0 -{ - public class IncreaseLanguageIsoCodeColumnLength : MigrationBase - { - public IncreaseLanguageIsoCodeColumnLength(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - // Some people seem to have a constraint in their DB instead of an index, we'd need to drop that one - // See: https://our.umbraco.com/forum/using-umbraco-and-getting-started/93282-upgrade-from-711-to-712-fails - var constraints = SqlSyntax.GetConstraintsPerTable(Context.Database).Distinct().ToArray(); - if (constraints.Any(x => x.Item2.InvariantEquals("IX_umbracoLanguage_languageISOCode"))) - { - Delete.UniqueConstraint("IX_umbracoLanguage_languageISOCode").FromTable("umbracoLanguage").Do(); - } - - //Now check for indexes of that name and drop that if it exists - var dbIndexes = SqlSyntax.GetDefinedIndexesDefinitions(Context.Database); - if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_umbracoLanguage_languageISOCode"))) - { - Delete.Index("IX_umbracoLanguage_languageISOCode").OnTable("umbracoLanguage").Do(); - } - - Alter.Table("umbracoLanguage") - .AlterColumn("languageISOCode") - .AsString(14) - .Nullable() - .Do(); - - Create.Index("IX_umbracoLanguage_languageISOCode") - .OnTable("umbracoLanguage") - .OnColumn("languageISOCode") - .Ascending() - .WithOptions() - .Unique() - .Do(); - } - - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/RenameTrueFalseField.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/RenameTrueFalseField.cs deleted file mode 100644 index 4022739ece..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/RenameTrueFalseField.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Umbraco.Core.Logging; -using Umbraco.Core.Persistence.Dtos; -using Umbraco.Core.Persistence.SqlSyntax; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_12_0 -{ - public class RenameTrueFalseField : MigrationBase - { - public RenameTrueFalseField(IMigrationContext context) : base(context) - { - } - - public override void Migrate() - { - //rename the existing true/false field - Update.Table(NodeDto.TableName).Set(new { text = "Checkbox" }).Where(new { id = Constants.DataTypes.Boolean }).Do(); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/SetDefaultTagsStorageType.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/SetDefaultTagsStorageType.cs deleted file mode 100644 index c8d65961f4..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/SetDefaultTagsStorageType.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Umbraco.Core.Models; -using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Dtos; -using Umbraco.Core.PropertyEditors; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_12_0 -{ - /// - /// Set the default storageType for the tags datatype to "CSV" to ensure backwards compatibility since the default is going to be JSON in new versions. - /// - public class SetDefaultTagsStorageType : MigrationBase - { - public SetDefaultTagsStorageType(IMigrationContext context) - : base(context) - { } - - // dummy editor for deserialization - private class TagConfigurationEditor : ConfigurationEditor - { } - - public override void Migrate() - { - // get all Umbraco.Tags datatypes - var dataTypeDtos = Database.Fetch(Context.SqlContext.Sql() - .Select() - .From() - .Where(x => x.EditorAlias == Constants.PropertyEditors.Aliases.Tags)); - - // get a dummy editor for deserialization - var editor = new TagConfigurationEditor(); - - foreach (var dataTypeDto in dataTypeDtos) - { - // need to check storageType on raw dictionary, as TagConfiguration would have a default value - var dictionary = JsonConvert.DeserializeObject(dataTypeDto.Configuration); - - // if missing, use TagConfiguration to properly update the configuration - // due to ... reasons ... the key can start with a lower or upper 'S' - if (!dictionary.ContainsKey("storageType") && !dictionary.ContainsKey("StorageType")) - { - var configuration = (TagConfiguration)editor.FromDatabase(dataTypeDto.Configuration); - configuration.StorageType = TagsStorageType.Csv; - dataTypeDto.Configuration = ConfigurationEditor.ToDatabase(configuration); - Database.Update(dataTypeDto); - } - } - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/UpdateUmbracoConsent.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/UpdateUmbracoConsent.cs deleted file mode 100644 index 7596e3d7dd..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_12_0/UpdateUmbracoConsent.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_12_0 -{ public class UpdateUmbracoConsent : MigrationBase { - public UpdateUmbracoConsent(IMigrationContext context) - : base(context) - { } - - public override void Migrate() { Alter.Table(Constants.DatabaseSchema.Tables.Consent).AlterColumn("comment").AsString().Nullable().Do(); } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_14_0/UpdateMemberGroupPickerData.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_14_0/UpdateMemberGroupPickerData.cs deleted file mode 100644 index c70f42076f..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_14_0/UpdateMemberGroupPickerData.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace Umbraco.Core.Migrations.Upgrade.V_7_14_0 -{ - /// - /// Migrates member group picker properties from NVarchar to NText. See https://github.com/umbraco/Umbraco-CMS/issues/3268. - /// - public class UpdateMemberGroupPickerData : MigrationBase - { - /// - /// Migrates member group picker properties from NVarchar to NText. See https://github.com/umbraco/Umbraco-CMS/issues/3268. - /// - public UpdateMemberGroupPickerData(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - Database.Execute($@"UPDATE umbracoPropertyData SET textValue = varcharValue, varcharValue = NULL - WHERE textValue IS NULL AND id IN ( - SELECT id FROM umbracoPropertyData WHERE propertyTypeId in ( - SELECT id from cmsPropertyType where dataTypeId IN ( - SELECT nodeId FROM umbracoDataType WHERE propertyEditorAlias = '{Constants.PropertyEditors.Aliases.MemberGroupPicker}' - ) - ) - )"); - - Database.Execute($"UPDATE umbracoDataType SET dbType = 'Ntext' WHERE propertyEditorAlias = '{Constants.PropertyEditors.Aliases.MemberGroupPicker}'"); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_5_0/AddRedirectUrlTable.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_5_0/AddRedirectUrlTable.cs deleted file mode 100644 index 7040874a74..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_5_0/AddRedirectUrlTable.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Linq; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_5_0 -{ - public class AddRedirectUrlTable : MigrationBase - { - public AddRedirectUrlTable(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var database = Database; - var umbracoRedirectUrlTableName = "umbracoRedirectUrl"; - - var tables = SqlSyntax.GetTablesInSchema(database).ToArray(); - - if (tables.InvariantContains(umbracoRedirectUrlTableName)) - { - var columns = SqlSyntax.GetColumnsInSchema(database).ToArray(); - if (columns.Any(x => x.TableName.InvariantEquals(umbracoRedirectUrlTableName) && x.ColumnName.InvariantEquals("id") && x.DataType == "uniqueidentifier")) - return; - Delete.Table(umbracoRedirectUrlTableName).Do(); - } - - Create.Table(umbracoRedirectUrlTableName) - .WithColumn("id").AsGuid().NotNullable().PrimaryKey("PK_" + umbracoRedirectUrlTableName) - .WithColumn("createDateUtc").AsDateTime().NotNullable() - .WithColumn("url").AsString(2048).NotNullable() - .WithColumn("contentKey").AsGuid().NotNullable() - .WithColumn("urlHash").AsString(40).NotNullable() - .Do(); - - Create.Index("IX_" + umbracoRedirectUrlTableName).OnTable(umbracoRedirectUrlTableName) - .OnColumn("urlHash") - .Ascending() - .OnColumn("contentKey") - .Ascending() - .OnColumn("createDateUtc") - .Descending() - .WithOptions().NonClustered() - .Do(); - - Create.ForeignKey("FK_" + umbracoRedirectUrlTableName) - .FromTable(umbracoRedirectUrlTableName).ForeignColumn("contentKey") - .ToTable("umbracoNode").PrimaryColumn("uniqueID") - .Do(); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_5_0/RemoveStylesheetDataAndTablesAgain.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_5_0/RemoveStylesheetDataAndTablesAgain.cs deleted file mode 100644 index d27ed11a21..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_5_0/RemoveStylesheetDataAndTablesAgain.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Linq; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_5_0 -{ - /// - /// This is here to re-remove these tables, we dropped them in 7.3 but new installs created them again so we're going to re-drop them - /// - public class RemoveStylesheetDataAndTablesAgain : MigrationBase - { - public RemoveStylesheetDataAndTablesAgain(IMigrationContext context) - : base(context) - { - } - - public override void Migrate() - { - // these have been obsoleted, need to copy the values here - var stylesheetPropertyObjectType = new Guid("5555da4f-a123-42b2-4488-dcdfb25e4111"); - var stylesheetObjectType = new Guid("9F68DA4F-A3A8-44C2-8226-DCBD125E4840"); - - //Clear all stylesheet data if the tables exist - var tables = SqlSyntax.GetTablesInSchema(Context.Database).ToArray(); - if (tables.InvariantContains("cmsStylesheetProperty")) - { - Delete.FromTable("cmsStylesheetProperty").AllRows().Do(); - Delete.FromTable("umbracoNode").Row(new { nodeObjectType = stylesheetPropertyObjectType }).Do(); - - Delete.Table("cmsStylesheetProperty").Do(); - } - if (tables.InvariantContains("cmsStylesheet")) - { - Delete.FromTable("cmsStylesheet").AllRows().Do(); - Delete.FromTable("umbracoNode").Row(new { nodeObjectType = stylesheetObjectType }).Do(); - - Delete.Table("cmsStylesheet").Do(); - } - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_5_0/UpdateUniqueIndexOnPropertyData.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_5_0/UpdateUniqueIndexOnPropertyData.cs deleted file mode 100644 index 8c688cfd28..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_5_0/UpdateUniqueIndexOnPropertyData.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Linq; -using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.SqlSyntax; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_5_0 -{ - /// - /// See: http://issues.umbraco.org/issue/U4-8522 - /// - public class UpdateUniqueIndexOnPropertyData : MigrationBase - { - public UpdateUniqueIndexOnPropertyData(IMigrationContext context) - : base(context) - { - } - - public override void Migrate() - { - //Clear all stylesheet data if the tables exist - //tuple = tablename, indexname, columnname, unique - var indexes = SqlSyntax.GetDefinedIndexes(Context.Database).ToArray(); - var found = indexes.FirstOrDefault( - x => x.Item1.InvariantEquals("cmsPropertyData") - && x.Item2.InvariantEquals("IX_cmsPropertyData_1") - //we're searching for the old index which is not unique - && x.Item4 == false); - - if (found != null) - { - Database.Execute("DELETE FROM cmsPropertyData WHERE id NOT IN (SELECT MIN(id) FROM cmsPropertyData GROUP BY nodeId, versionId, propertytypeid HAVING MIN(id) IS NOT NULL)"); - - //we need to re create this index - Delete.Index("IX_cmsPropertyData_1").OnTable("cmsPropertyData").Do(); - Create.Index("IX_cmsPropertyData_1").OnTable("cmsPropertyData") - .OnColumn("nodeId").Ascending() - .OnColumn("versionId").Ascending() - .OnColumn("propertytypeid").Ascending() - .WithOptions().NonClustered() - .WithOptions().Unique() - .Do(); - } - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_5_5/UpdateAllowedMediaTypesAtRoot.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_5_5/UpdateAllowedMediaTypesAtRoot.cs deleted file mode 100644 index 362b8e251c..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_5_5/UpdateAllowedMediaTypesAtRoot.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Umbraco.Core.Migrations.Upgrade.V_7_5_5 -{ - /// - /// See: http://issues.umbraco.org/issue/U4-4196 - /// - public class UpdateAllowedMediaTypesAtRoot : MigrationBase - { - public UpdateAllowedMediaTypesAtRoot(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - Database.Execute("UPDATE cmsContentType SET allowAtRoot = 1 WHERE nodeId = 1032 OR nodeId = 1033"); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexToCmsMemberLoginName.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexToCmsMemberLoginName.cs deleted file mode 100644 index a223d76a07..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexToCmsMemberLoginName.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Linq; -using Umbraco.Core.Persistence.SqlSyntax; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_6_0 -{ - public class AddIndexToCmsMemberLoginName : MigrationBase - { - public AddIndexToCmsMemberLoginName(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var database = Database; - - //Now we need to check if we can actually d6 this because we won't be able to if there's data in there that is too long - //http://issues.umbraco.org/issue/U4-9758 - - var colLen = database.ExecuteScalar("select max(datalength(LoginName)) from cmsMember"); - - if (colLen < 900 == false && colLen != null) - { - return; - } - - var dbIndexes = SqlSyntax.GetDefinedIndexesDefinitions(Context.Database); - - //make sure it doesn't already exist - if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_cmsMember_LoginName")) == false) - { - //we can apply the index - Create.Index("IX_cmsMember_LoginName").OnTable("cmsMember") - .OnColumn("LoginName") - .Ascending() - .WithOptions() - .NonClustered() - .Do(); - } - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexToUmbracoNodePath.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexToUmbracoNodePath.cs deleted file mode 100644 index 191f410b47..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexToUmbracoNodePath.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Linq; -using Umbraco.Core.Persistence.SqlSyntax; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_6_0 -{ - public class AddIndexToUmbracoNodePath : MigrationBase - { - public AddIndexToUmbracoNodePath(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var dbIndexes = SqlSyntax.GetDefinedIndexesDefinitions(Context.Database); - - //make sure it doesn't already exist - if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_umbracoNodePath")) == false) - { - Create.Index("IX_umbracoNodePath").OnTable("umbracoNode") - .OnColumn("path") - .Ascending() - .WithOptions() - .NonClustered() - .Do(); - } - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexToUser2NodePermission.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexToUser2NodePermission.cs deleted file mode 100644 index 87b392b09c..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexToUser2NodePermission.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Linq; -using Umbraco.Core.Persistence.SqlSyntax; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_6_0 -{ - public class AddIndexToUser2NodePermission : MigrationBase - { - public AddIndexToUser2NodePermission(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var dbIndexes = SqlSyntax.GetDefinedIndexesDefinitions(Context.Database); - - //make sure it doesn't already exist - if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_umbracoUser2NodePermission_nodeId")) == false) - { - Create.Index("IX_umbracoUser2NodePermission_nodeId").OnTable("umbracoUser2NodePermission") - .OnColumn("nodeId") - .Ascending() - .WithOptions() - .NonClustered() - .Do(); - } - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexesToUmbracoRelationTables.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexesToUmbracoRelationTables.cs deleted file mode 100644 index 9042ae105e..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddIndexesToUmbracoRelationTables.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Linq; -using Umbraco.Core.Persistence.SqlSyntax; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_6_0 -{ - public class AddIndexesToUmbracoRelationTables : MigrationBase - { - public AddIndexesToUmbracoRelationTables(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var dbIndexes = SqlSyntax.GetDefinedIndexesDefinitions(Context.Database).ToArray(); - - //make sure it doesn't already exist - if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_umbracoRelation_parentChildType")) == false) - { - //This will remove any corrupt/duplicate data in the relation table before the index is applied - //Ensure this executes in a deferred block which will be done inside of the migration transaction - var database = Database; - - //We need to check if this index has corrupted data and then clear that data - var duplicates = database.Fetch("SELECT parentId,childId,relType FROM umbracoRelation GROUP BY parentId,childId,relType HAVING COUNT(*) > 1"); - if (duplicates.Count > 0) - { - //need to fix this there cannot be duplicates so we'll take the latest entries, it's really not going to matter though - foreach (var duplicate in duplicates) - { - var ids = database.Fetch("SELECT id FROM umbracoRelation WHERE parentId=@parentId AND childId=@childId AND relType=@relType ORDER BY datetime DESC", - new { parentId = duplicate.parentId, childId = duplicate.childId, relType = duplicate.relType }); - - if (ids.Count == 1) - { - //this is just a safety check, this should absolutely never happen - throw new InvalidOperationException("Duplicates were detected but could not be discovered"); - } - - //delete the others - ids = ids.Skip(0).ToList(); - - //iterate in groups of 2000 to avoid the max sql parameter limit - foreach (var idGroup in ids.InGroupsOf(2000)) - { - database.Execute("DELETE FROM umbracoRelation WHERE id IN (@ids)", new { ids = idGroup }); - } - } - } - - //unique index to prevent duplicates - and for better perf - Create.Index("IX_umbracoRelation_parentChildType").OnTable("umbracoRelation") - .OnColumn("parentId").Ascending() - .OnColumn("childId").Ascending() - .OnColumn("relType").Ascending() - .WithOptions() - .Unique() - .Do(); - } - - //need indexes on alias and name for relation type since these are queried against - - //make sure it doesn't already exist - if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_umbracoRelationType_alias")) == false) - { - Create.Index("IX_umbracoRelationType_alias").OnTable("umbracoRelationType") - .OnColumn("alias") - .Ascending() - .WithOptions() - .NonClustered() - .Do(); - } - if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_umbracoRelationType_name")) == false) - { - Create.Index("IX_umbracoRelationType_name").OnTable("umbracoRelationType") - .OnColumn("name") - .Ascending() - .WithOptions() - .NonClustered() - .Do(); - } - - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddLockObjects.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddLockObjects.cs deleted file mode 100644 index 2cc62cd2f9..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddLockObjects.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Umbraco.Core.Persistence.Dtos; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_6_0 -{ - public class AddLockObjects : MigrationBase - { - public AddLockObjects(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - EnsureLockObject(Constants.Locks.Servers, "Servers"); - } - - private void EnsureLockObject(int id, string name) - { - var db = Database; - var exists = db.Exists(id); - if (exists) return; - // be safe: delete old umbracoNode lock objects if any - db.Execute("DELETE FROM umbracoNode WHERE id=@id;", new { id }); - // then create umbracoLock object - db.Execute("INSERT umbracoLock (id, name, value) VALUES (@id, @name, 1);", new { id, name }); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddLockTable.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddLockTable.cs deleted file mode 100644 index 369bda0758..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddLockTable.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Linq; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_6_0 -{ - public class AddLockTable : MigrationBase - { - public AddLockTable(IMigrationContext context) - : base(context) - { } - - 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(); - } - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddMacroUniqueIdColumn.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddMacroUniqueIdColumn.cs deleted file mode 100644 index 82888ab970..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddMacroUniqueIdColumn.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Linq; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_6_0 -{ - public class AddMacroUniqueIdColumn : MigrationBase - { - public AddMacroUniqueIdColumn(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); - - if (columns.Any(x => x.TableName.InvariantEquals("cmsMacro") && x.ColumnName.InvariantEquals("uniqueId")) == false) - { - Create.Column("uniqueId").OnTable("cmsMacro").AsGuid().Nullable().Do(); - UpdateMacroGuids(); - Alter.Table("cmsMacro").AlterColumn("uniqueId").AsGuid().NotNullable().Do(); - Create.Index("IX_cmsMacro_UniqueId").OnTable("cmsMacro").OnColumn("uniqueId") - .Ascending() - .WithOptions().NonClustered() - .WithOptions().Unique() - .Do(); - - } - - if (columns.Any(x => x.TableName.InvariantEquals("cmsMacroProperty") && x.ColumnName.InvariantEquals("uniquePropertyId")) == false) - { - Create.Column("uniquePropertyId").OnTable("cmsMacroProperty").AsGuid().Nullable().Do(); - UpdateMacroPropertyGuids(); - Alter.Table("cmsMacroProperty").AlterColumn("uniquePropertyId").AsGuid().NotNullable().Do(); - Create.Index("IX_cmsMacroProperty_UniquePropertyId").OnTable("cmsMacroProperty").OnColumn("uniquePropertyId") - .Ascending() - .WithOptions().NonClustered() - .WithOptions().Unique() - .Do(); - } - } - - private void UpdateMacroGuids() - { - var database = Database; - - var updates = database.Query("SELECT id, macroAlias FROM cmsMacro") - .Select(macro => Tuple.Create((int) macro.id, ("macro____" + (string) macro.macroAlias).ToGuid())) - .ToList(); - - foreach (var update in updates) - database.Execute("UPDATE cmsMacro set uniqueId=@guid WHERE id=@id", new { guid = update.Item2, id = update.Item1 }); - } - - private void UpdateMacroPropertyGuids() - { - var database = Database; - - var updates = database.Query(@"SELECT cmsMacroProperty.id id, macroPropertyAlias propertyAlias, cmsMacro.macroAlias macroAlias -FROM cmsMacroProperty -JOIN cmsMacro ON cmsMacroProperty.macro=cmsMacro.id") - .Select(prop => Tuple.Create((int) prop.id, ("macro____" + (string) prop.macroAlias + "____" + (string) prop.propertyAlias).ToGuid())) - .ToList(); - - foreach (var update in updates) - database.Execute("UPDATE cmsMacroProperty set uniquePropertyId=@guid WHERE id=@id", new { guid = update.Item2, id = update.Item1 }); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddRelationTypeUniqueIdColumn.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddRelationTypeUniqueIdColumn.cs deleted file mode 100644 index e166a4582d..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/AddRelationTypeUniqueIdColumn.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Linq; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_6_0 -{ - public class AddRelationTypeUniqueIdColumn : MigrationBase - { - public AddRelationTypeUniqueIdColumn(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); - - if (columns.Any(x => x.TableName.InvariantEquals("umbracoRelationType") && x.ColumnName.InvariantEquals("typeUniqueId")) == false) - { - Create.Column("typeUniqueId").OnTable("umbracoRelationType").AsGuid().Nullable().Do(); - UpdateRelationTypeGuids(); - Alter.Table("umbracoRelationType").AlterColumn("typeUniqueId").AsGuid().NotNullable().Do(); - Create.Index("IX_umbracoRelationType_UniqueId").OnTable("umbracoRelationType").OnColumn("typeUniqueId") - .Ascending() - .WithOptions().NonClustered() - .WithOptions().Unique() - .Do(); - } - } - - private void UpdateRelationTypeGuids() - { - var database = Database; - var updates = database.Query("SELECT id, alias, name FROM umbracoRelationType") - .Select(relationType => Tuple.Create((int) relationType.id, ("relationType____" + (string) relationType.alias + "____" + (string) relationType.name).ToGuid())) - .ToList(); - - foreach (var update in updates) - database.Execute("UPDATE umbracoRelationType set typeUniqueId=@guid WHERE id=@id", new { guid = update.Item2, id = update.Item1 }); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/NormalizeTemplateGuids.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/NormalizeTemplateGuids.cs deleted file mode 100644 index 9e8c739104..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/NormalizeTemplateGuids.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Linq; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_6_0 -{ - public class NormalizeTemplateGuids : MigrationBase - { - public NormalizeTemplateGuids(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var database = Database; - - // we need this migration because ppl running pre-7.6 on Cloud and Courier have templates in different - // environments having different GUIDs (Courier does not sync template GUIDs) and we need to normalize - // these GUIDs so templates with the same alias on different environments have the same GUID. - // however, if already running a prerelease version of 7.6, we do NOT want to normalize the GUIDs as quite - // probably, we are already running Deploy and the GUIDs are OK. assuming noone is running a prerelease - // of 7.6 on Courier. - // so... testing if we already have a 7.6.0 version installed. not pretty but...? - // - var version = database.FirstOrDefault("SELECT version FROM umbracoMigration WHERE name=@name ORDER BY version DESC", new { name = Constants.System.UmbracoUpgradePlanName }); - if (version != null && version.StartsWith("7.6.0")) return; - - var updates = database.Query(@"SELECT umbracoNode.id, cmsTemplate.alias FROM umbracoNode -JOIN cmsTemplate ON umbracoNode.id=cmsTemplate.nodeId -WHERE nodeObjectType = @guid", new { guid = Constants.ObjectTypes.TemplateType }) - .Select(template => Tuple.Create((int) template.id, ("template____" + (string) template.alias).ToGuid())) - .ToList(); - - foreach (var update in updates) - database.Execute("UPDATE umbracoNode set uniqueId=@guid WHERE id=@id", new { guid = update.Item2, id = update.Item1 }); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/ReduceLoginNameColumnsSize.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/ReduceLoginNameColumnsSize.cs deleted file mode 100644 index 1af21617f3..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/ReduceLoginNameColumnsSize.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Linq; -using Umbraco.Core.Persistence.SqlSyntax; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_6_0 -{ - public class ReduceLoginNameColumnsSize : MigrationBase - { - public ReduceLoginNameColumnsSize(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - //Now we need to check if we can actually d6 this because we won't be able to if there's data in there that is too long - //http://issues.umbraco.org/issue/U4-9758 - - var database = Database; - var dbIndexes = SqlSyntax.GetDefinedIndexesDefinitions(database); - - var colLen = database.ExecuteScalar("select max(datalength(LoginName)) from cmsMember"); - - if (colLen < 900 == false) return; - - //if an index exists on this table we need to drop it. Normally we'd check via index name but in some odd cases (i.e. Our) - //the index name is something odd (starts with "mi_"). In any case, the index cannot exist if we want to alter the column - //so we'll drop whatever index is there and add one with the correct name after. - var loginNameIndex = dbIndexes.FirstOrDefault(x => x.TableName.InvariantEquals("cmsMember") && x.ColumnName.InvariantEquals("LoginName")); - if (loginNameIndex != null) - { - Delete.Index(loginNameIndex.IndexName).OnTable("cmsMember").Do(); - } - - //we can apply the col length change - Alter.Table("cmsMember") - .AlterColumn("LoginName") - .AsString(225) - .NotNullable() - .Do(); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/RemovePropertyDataIdIndex.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/RemovePropertyDataIdIndex.cs deleted file mode 100644 index 804714d1ff..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/RemovePropertyDataIdIndex.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Linq; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_6_0 -{ - /// - /// See: http://issues.umbraco.org/issue/U4-9188 - /// - public class UpdateUniqueIndexOnPropertyData : MigrationBase - { - public UpdateUniqueIndexOnPropertyData(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - //tuple = tablename, indexname, columnname, unique - var indexes = SqlSyntax.GetDefinedIndexes(Context.Database).ToArray(); - var found = indexes.FirstOrDefault( - x => x.Item1.InvariantEquals("cmsPropertyData") - && x.Item2.InvariantEquals("IX_cmsPropertyData")); - - if (found != null) - { - //drop the index - Delete.Index("IX_cmsPropertyData").OnTable("cmsPropertyData").Do(); - } - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/RemoveUmbracoDeployTables.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/RemoveUmbracoDeployTables.cs deleted file mode 100644 index 744b441b32..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_6_0/RemoveUmbracoDeployTables.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Linq; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_6_0 -{ - public class RemoveUmbracoDeployTables : MigrationBase - { - public RemoveUmbracoDeployTables(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var tables = SqlSyntax.GetTablesInSchema(Context.Database).ToArray(); - - // there are two versions of umbracoDeployDependency, - // 1. one created by 7.4 and never used, we need to remove it (has a sourceId column) - // 2. one created by Deploy itself, we need to keep it (has a sourceUdi column) - if (tables.InvariantContains("umbracoDeployDependency")) - { - var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); - if (columns.Any(x => x.TableName.InvariantEquals("umbracoDeployDependency") && x.ColumnName.InvariantEquals("sourceId"))) - Delete.Table("umbracoDeployDependency").Do(); - } - - // always remove umbracoDeployChecksum - if (tables.InvariantContains("umbracoDeployChecksum")) - Delete.Table("umbracoDeployChecksum").Do(); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddIndexToDictionaryKeyColumn.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddIndexToDictionaryKeyColumn.cs deleted file mode 100644 index b366c7dab9..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddIndexToDictionaryKeyColumn.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Linq; -using Umbraco.Core.Persistence.SqlSyntax; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_7_0 -{ - public class AddIndexToDictionaryKeyColumn : MigrationBase - { - public AddIndexToDictionaryKeyColumn(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var database = Database; - //Now we need to check if we can actually do this because we won't be able to if there's data in there that is too long - var colLen = database.ExecuteScalar(string.Format("select max(datalength({0})) from cmsDictionary", SqlSyntax.GetQuotedColumnName("key"))); - - if (colLen < 900 == false && colLen != null) - { - return; - } - - var dbIndexes = SqlSyntax.GetDefinedIndexesDefinitions(Context.Database); - - //make sure it doesn't already exist - if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_cmsDictionary_key")) == false) - { - //we can apply the index - Create.Index("IX_cmsDictionary_key").OnTable("cmsDictionary") - .OnColumn("key") - .Ascending() - .WithOptions() - .NonClustered() - .Do(); - } - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddUserGroupTables.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddUserGroupTables.cs deleted file mode 100644 index edd78e6c84..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddUserGroupTables.cs +++ /dev/null @@ -1,357 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Dtos; -using ColumnInfo = Umbraco.Core.Persistence.SqlSyntax.ColumnInfo; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_7_0 -{ - public class AddUserGroupTables : MigrationBase - { - private readonly string _collateSyntax; - - public AddUserGroupTables(IMigrationContext context) - : base(context) - { - //For some of the migration data inserts we require to use a special MSSQL collate expression since - //some databases may have a custom collation specified and if that is the case, when we compare strings - //in dynamic SQL it will try to compare strings in different collations and this will yield errors. - _collateSyntax = "COLLATE DATABASE_DEFAULT"; - } - - public override void Migrate() - { - var tables = SqlSyntax.GetTablesInSchema(Context.Database).ToList(); - var constraints = SqlSyntax.GetConstraintsPerColumn(Context.Database).Distinct().ToArray(); - var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); - - //In some very rare cases, there might already be user group tables that we'll need to remove first - //but of course we don't want to remove the tables we will be creating below if they already exist so - //need to do some checks first since these old rare tables have a different schema - RemoveOldTablesIfExist(tables, columns); - - if (AddNewTables(tables)) - { - MigrateUserPermissions(); - MigrateUserTypesToGroups(); - DeleteOldTables(tables, constraints); - SetDefaultIcons(); - } - else - { - //if we aren't adding the tables, make sure that the umbracoUserGroup table has the correct FKs - these - //were added after the beta release so we need to do some cleanup - //if the FK doesn't exist - if (constraints.Any(x => x.Item1.InvariantEquals("umbracoUserGroup") - && x.Item2.InvariantEquals("startContentId") - && x.Item3.InvariantEquals("FK_startContentId_umbracoNode_id")) == false) - { - //before we add any foreign key we need to make sure there's no stale data in there which would have happened in the beta - //release if a start node was assigned and then that start node was deleted. - Database.Execute(@"UPDATE umbracoUserGroup SET startContentId = NULL WHERE startContentId NOT IN (SELECT id FROM umbracoNode)"); - - Create.ForeignKey("FK_startContentId_umbracoNode_id") - .FromTable("umbracoUserGroup") - .ForeignColumn("startContentId") - .ToTable("umbracoNode") - .PrimaryColumn("id") - .OnDelete(Rule.None) - .OnUpdate(Rule.None) - .Do(); - } - - if (constraints.Any(x => x.Item1.InvariantEquals("umbracoUserGroup") - && x.Item2.InvariantEquals("startMediaId") - && x.Item3.InvariantEquals("FK_startMediaId_umbracoNode_id")) == false) - { - //before we add any foreign key we need to make sure there's no stale data in there which would have happened in the beta - //release if a start node was assigned and then that start node was deleted. - Database.Execute(@"UPDATE umbracoUserGroup SET startMediaId = NULL WHERE startMediaId NOT IN (SELECT id FROM umbracoNode)"); - - Create.ForeignKey("FK_startMediaId_umbracoNode_id") - .FromTable("umbracoUserGroup") - .ForeignColumn("startMediaId") - .ToTable("umbracoNode") - .PrimaryColumn("id") - .OnDelete(Rule.None) - .OnUpdate(Rule.None) - .Do(); - } - } - } - - /// - /// In some very rare cases, there might already be user group tables that we'll need to remove first - /// but of course we don't want to remove the tables we will be creating below if they already exist so - /// need to do some checks first since these old rare tables have a different schema - /// - /// - /// - private void RemoveOldTablesIfExist(List tables, ColumnInfo[] columns) - { - if (tables.Contains("umbracoUser2userGroup", StringComparer.InvariantCultureIgnoreCase)) - { - //this column doesn't exist in the 7.7 schema, so if it's there, then this is a super old table - var foundOldColumn = columns - .FirstOrDefault(x => - x.ColumnName.Equals("user", StringComparison.InvariantCultureIgnoreCase) - && x.TableName.Equals("umbracoUser2userGroup", StringComparison.InvariantCultureIgnoreCase)); - if (foundOldColumn != null) - { - Delete.Table("umbracoUser2userGroup").Do(); - //remove from the tables list since this will be re-checked in further logic - tables.Remove("umbracoUser2userGroup"); - } - } - - if (tables.Contains("umbracoUserGroup", StringComparer.InvariantCultureIgnoreCase)) - { - //The new schema has several columns, the super old one for this table only had 2 so if it's 2 get rid of it - var countOfCols = columns - .Count(x => x.TableName.Equals("umbracoUserGroup", StringComparison.InvariantCultureIgnoreCase)); - if (countOfCols == 2) - { - Delete.Table("umbracoUserGroup").Do(); - //remove from the tables list since this will be re-checked in further logic - tables.Remove("umbracoUserGroup"); - } - } - } - - private void SetDefaultIcons() - { - Database.Execute($"UPDATE umbracoUserGroup SET icon = \'\' WHERE userGroupAlias = \'{Constants.Security.AdminGroupAlias}\'"); - Database.Execute("UPDATE umbracoUserGroup SET icon = \'icon-edit\' WHERE userGroupAlias = \'writer\'"); - Database.Execute("UPDATE umbracoUserGroup SET icon = \'icon-tools\' WHERE userGroupAlias = \'editor\'"); - Database.Execute("UPDATE umbracoUserGroup SET icon = \'icon-globe\' WHERE userGroupAlias = \'translator\'"); - } - - private bool AddNewTables(List tables) - { - var updated = false; - if (tables.InvariantContains("umbracoUserGroup") == false) - { - Create.Table().Do(); - updated = true; - } - - if (tables.InvariantContains("umbracoUser2UserGroup") == false) - { - Create.Table().Do(); - updated = true; - } - - if (tables.InvariantContains("umbracoUserGroup2App") == false) - { - Create.Table().Do(); - updated = true; - } - - if (tables.InvariantContains("umbracoUserGroup2NodePermission") == false) - { - Create.Table().Do(); - updated = true; - } - - return updated; - } - - private void MigrateUserTypesToGroups() - { - // Create a user group for each user type - Database.Execute(@"INSERT INTO umbracoUserGroup (userGroupAlias, userGroupName, userGroupDefaultPermissions) - SELECT userTypeAlias, userTypeName, userTypeDefaultPermissions - FROM umbracoUserType"); - - // Add each user to the group created from their type - Database.Execute(string.Format(@"INSERT INTO umbracoUser2UserGroup (userId, userGroupId) - SELECT u.id, ug.id - FROM umbracoUser u - INNER JOIN umbracoUserType ut ON ut.id = u.userType - INNER JOIN umbracoUserGroup ug ON ug.userGroupAlias {0} = ut.userTypeAlias {0}", _collateSyntax)); - - // Add the built-in administrator account to all apps - // this will lookup all of the apps that the admin currently has access to in order to assign the sections - // instead of use statically assigning since there could be extra sections we don't know about. - Database.Execute(@"INSERT INTO umbracoUserGroup2app (userGroupId,app) - SELECT ug.id, app - FROM umbracoUserGroup ug - INNER JOIN umbracoUser2UserGroup u2ug ON u2ug.userGroupId = ug.id - INNER JOIN umbracoUser u ON u.id = u2ug.userId - INNER JOIN umbracoUser2app u2a ON u2a." + SqlSyntax.GetQuotedColumnName("user") + @" = u.id - WHERE u.id = 0"); - - // Add the default section access to the other built-in accounts - // writer: - Database.Execute(string.Format(@"INSERT INTO umbracoUserGroup2app (userGroupId, app) - SELECT ug.id, 'content' as app - FROM umbracoUserGroup ug - WHERE ug.userGroupAlias {0} = 'writer' {0}", _collateSyntax)); - // editor - Database.Execute(string.Format(@"INSERT INTO umbracoUserGroup2app (userGroupId, app) - SELECT ug.id, 'content' as app - FROM umbracoUserGroup ug - WHERE ug.userGroupAlias {0} = 'editor' {0}", _collateSyntax)); - Database.Execute(string.Format(@"INSERT INTO umbracoUserGroup2app (userGroupId, app) - SELECT ug.id, 'media' as app - FROM umbracoUserGroup ug - WHERE ug.userGroupAlias {0} = 'editor' {0}", _collateSyntax)); - // translator - Database.Execute(string.Format(@"INSERT INTO umbracoUserGroup2app (userGroupId, app) - SELECT ug.id, 'translation' as app - FROM umbracoUserGroup ug - WHERE ug.userGroupAlias {0} = 'translator' {0}", _collateSyntax)); - - //We need to lookup all distinct combinations of section access and create a group for each distinct collection - //and assign groups accordingly. We'll perform the lookup 'now' to then create the queued SQL migrations. - var userAppsData = Context.Database.Query(@"SELECT u.id, u2a.app FROM umbracoUser u - INNER JOIN umbracoUser2app u2a ON u2a." + SqlSyntax.GetQuotedColumnName("user") + @" = u.id - ORDER BY u.id, u2a.app"); - var usersWithApps = new Dictionary>(); - foreach (var userApps in userAppsData) - { - if (usersWithApps.TryGetValue(userApps.id, out List apps) == false) - { - apps = new List {userApps.app}; - usersWithApps.Add(userApps.id, apps); - } - else - { - apps.Add(userApps.app); - } - } - //At this stage we have a dictionary of users with a collection of their apps which are sorted - //and we need to determine the unique/distinct app collections for each user to create groups with. - //We can do this by creating a hash value of all of the app values and since they are already sorted we can get a distinct - //collection by this hash. - var distinctApps = usersWithApps - .Select(x => new {appCollection = x.Value, appsHash = string.Join("", x.Value).GenerateHash()}) - .DistinctBy(x => x.appsHash) - .ToArray(); - //Now we need to create user groups for each of these distinct app collections, and then assign the corresponding users to those groups - for (var i = 0; i < distinctApps.Length; i++) - { - //create the group - var alias = "MigratedSectionAccessGroup_" + (i + 1); - Insert.IntoTable("umbracoUserGroup").Row(new - { - userGroupAlias = "MigratedSectionAccessGroup_" + (i + 1), - userGroupName = "Migrated Section Access Group " + (i + 1) - }).Do(); - //now assign the apps - var distinctApp = distinctApps[i]; - foreach (var app in distinctApp.appCollection) - { - Database.Execute(string.Format(@"INSERT INTO umbracoUserGroup2app (userGroupId, app) - SELECT ug.id, '" + app + @"' as app - FROM umbracoUserGroup ug - WHERE ug.userGroupAlias {0} = '" + alias + "' {0}", _collateSyntax)); - } - //now assign the corresponding users to this group - foreach (var userWithApps in usersWithApps) - { - //check if this user's groups hash matches the current groups hash - var hash = string.Join("", userWithApps.Value).GenerateHash(); - if (hash == distinctApp.appsHash) - { - //it matches so assign the user to this group - Database.Execute(string.Format(@"INSERT INTO umbracoUser2UserGroup (userId, userGroupId) - SELECT " + userWithApps.Key + @", ug.id - FROM umbracoUserGroup ug - WHERE ug.userGroupAlias {0} = '" + alias + "' {0}", _collateSyntax)); - } - } - } - - // Rename some groups for consistency (plural form) - Database.Execute("UPDATE umbracoUserGroup SET userGroupName = 'Writers' WHERE userGroupAlias = 'writer'"); - Database.Execute("UPDATE umbracoUserGroup SET userGroupName = 'Translators' WHERE userGroupAlias = 'translator'"); - - //Ensure all built in groups have a start node of -1 - Database.Execute("UPDATE umbracoUserGroup SET startContentId = -1 WHERE userGroupAlias = 'editor'"); - Database.Execute("UPDATE umbracoUserGroup SET startMediaId = -1 WHERE userGroupAlias = 'editor'"); - Database.Execute("UPDATE umbracoUserGroup SET startContentId = -1 WHERE userGroupAlias = 'writer'"); - Database.Execute("UPDATE umbracoUserGroup SET startMediaId = -1 WHERE userGroupAlias = 'writer'"); - Database.Execute("UPDATE umbracoUserGroup SET startContentId = -1 WHERE userGroupAlias = 'translator'"); - Database.Execute("UPDATE umbracoUserGroup SET startMediaId = -1 WHERE userGroupAlias = 'translator'"); - Database.Execute("UPDATE umbracoUserGroup SET startContentId = -1 WHERE userGroupAlias = 'admin'"); - Database.Execute("UPDATE umbracoUserGroup SET startMediaId = -1 WHERE userGroupAlias = 'admin'"); - } - - private void MigrateUserPermissions() - { - // Create user group records for all non-admin users that have specific permissions set - Database.Execute(@"INSERT INTO umbracoUserGroup(userGroupAlias, userGroupName) - SELECT 'permissionGroupFor' + userLogin, 'Migrated Permission Group for ' + userLogin - FROM umbracoUser - WHERE (id IN ( - SELECT userid - FROM umbracoUser2NodePermission - )) - AND id > 0"); - - // Associate those groups with the users - Database.Execute(string.Format(@"INSERT INTO umbracoUser2UserGroup (userId, userGroupId) - SELECT u.id, ug.id - FROM umbracoUser u - INNER JOIN umbracoUserGroup ug ON ug.userGroupAlias {0} = 'permissionGroupFor' + userLogin {0}", _collateSyntax)); - - // Create node permissions on the groups - Database.Execute(string.Format(@"INSERT INTO umbracoUserGroup2NodePermission (userGroupId,nodeId,permission) - SELECT ug.id, nodeId, permission - FROM umbracoUserGroup ug - INNER JOIN umbracoUser2UserGroup u2ug ON u2ug.userGroupId = ug.id - INNER JOIN umbracoUser u ON u.id = u2ug.userId - INNER JOIN umbracoUser2NodePermission u2np ON u2np.userId = u.id - WHERE ug.userGroupAlias {0} NOT IN ( - SELECT userTypeAlias {0} - FROM umbracoUserType - )", _collateSyntax)); - - // Create app permissions on the groups - Database.Execute(string.Format(@"INSERT INTO umbracoUserGroup2app (userGroupId,app) - SELECT ug.id, app - FROM umbracoUserGroup ug - INNER JOIN umbracoUser2UserGroup u2ug ON u2ug.userGroupId = ug.id - INNER JOIN umbracoUser u ON u.id = u2ug.userId - INNER JOIN umbracoUser2app u2a ON u2a." + SqlSyntax.GetQuotedColumnName("user") + @" = u.id - WHERE ug.userGroupAlias {0} NOT IN ( - SELECT userTypeAlias {0} - FROM umbracoUserType - )", _collateSyntax)); - } - - private void DeleteOldTables(List tables, Tuple[] constraints) - { - if (tables.InvariantContains("umbracoUser2App")) - { - Delete.Table("umbracoUser2App").Do(); - } - - if (tables.InvariantContains("umbracoUser2NodePermission")) - { - Delete.Table("umbracoUser2NodePermission").Do(); - } - - if (tables.InvariantContains("umbracoUserType") && tables.InvariantContains("umbracoUser")) - { - //Delete the FK if it exists before dropping the column - if (constraints.Any(x => x.Item1.InvariantEquals("umbracoUser") && x.Item3.InvariantEquals("FK_umbracoUser_umbracoUserType_id"))) - { - Delete.ForeignKey("FK_umbracoUser_umbracoUserType_id").OnTable("umbracoUser").Do(); - } - - //This is the super old constraint name of the FK for user type so check this one too - if (constraints.Any(x => x.Item1.InvariantEquals("umbracoUser") && x.Item3.InvariantEquals("FK_user_userType"))) - { - Delete.ForeignKey("FK_user_userType").OnTable("umbracoUser").Do(); - } - - Delete.Column("userType").FromTable("umbracoUser").Do(); - Delete.Table("umbracoUserType").Do(); - } - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddUserStartNodeTable.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddUserStartNodeTable.cs deleted file mode 100644 index 54545e06d3..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/AddUserStartNodeTable.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Linq; -using Umbraco.Core.Persistence.Dtos; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_7_0 -{ - public class AddUserStartNodeTable : MigrationBase - { - public AddUserStartNodeTable(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var tables = SqlSyntax.GetTablesInSchema(Context.Database).ToArray(); - - if (tables.InvariantContains("umbracoUserStartNode")) return; - - Create.Table().Do(); - - MigrateUserStartNodes(); - - //now remove the old columns - - Delete.Column("startStructureID").FromTable("umbracoUser").Do(); - Delete.Column("startMediaID").FromTable("umbracoUser").Do(); - } - - private void MigrateUserStartNodes() - { - Database.Execute(@"INSERT INTO umbracoUserStartNode (userId, startNode, startNodeType) - SELECT id, startStructureID, 1 - FROM umbracoUser - WHERE startStructureID IS NOT NULL AND startStructureID > 0 AND startStructureID IN (SELECT id FROM umbracoNode WHERE nodeObjectType='" + Constants.ObjectTypes.Document + "')"); - - Database.Execute(@"INSERT INTO umbracoUserStartNode (userId, startNode, startNodeType) - SELECT id, startMediaID, 2 - FROM umbracoUser - WHERE startMediaID IS NOT NULL AND startMediaID > 0 AND startMediaID IN (SELECT id FROM umbracoNode WHERE nodeObjectType='" + Constants.ObjectTypes.Media + "')"); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/EnsureContentTemplatePermissions.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/EnsureContentTemplatePermissions.cs deleted file mode 100644 index 1f7e2faf33..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/EnsureContentTemplatePermissions.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Linq; -using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Dtos; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_7_0 -{ - /// - /// Ensures the built-in user groups have the blueprint permission by default on upgrade - /// - public class EnsureContentTemplatePermissions : MigrationBase - { - public EnsureContentTemplatePermissions(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var database = Database; - var userGroups = database.Fetch( - Context.SqlContext.Sql().Select("*") - .From() - .Where(x => x.Alias == "admin" || x.Alias == "editor")); - - foreach (var userGroup in userGroups) - { - if (userGroup.DefaultPermissions.Contains('�') == false) - { - userGroup.DefaultPermissions += "�"; - Update.Table("umbracoUserGroup") - .Set(new { userGroupDefaultPermissions = userGroup.DefaultPermissions }) - .Where(new { id = userGroup.Id }) - .Do(); - } - } - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/ReduceDictionaryKeyColumnsSize.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/ReduceDictionaryKeyColumnsSize.cs deleted file mode 100644 index 17dd3064eb..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/ReduceDictionaryKeyColumnsSize.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Linq; -using Umbraco.Core.Persistence.SqlSyntax; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_7_0 -{ - public class ReduceDictionaryKeyColumnsSize : MigrationBase - { - public ReduceDictionaryKeyColumnsSize(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - //Now we need to check if we can actually do this because we won't be able to if there's data in there that is too long - - var database = Database; - var dbIndexes = SqlSyntax.GetDefinedIndexesDefinitions(database); - - var colLen = database.ExecuteScalar(string.Format("select max(datalength({0})) from cmsDictionary", SqlSyntax.GetQuotedColumnName("key"))); - - if (colLen < 900 == false) return; - - //if it exists we need to drop it first - if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_cmsDictionary_key"))) - { - Delete.Index("IX_cmsDictionary_key").OnTable("cmsDictionary").Do(); - } - - //we can apply the col length change - Alter.Table("cmsDictionary") - .AlterColumn("key") - .AsString(450) - .NotNullable() - .Do(); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/UpdateUserTables.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/UpdateUserTables.cs deleted file mode 100644 index 509b3f91dd..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_7_0/UpdateUserTables.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Linq; -using System.Web.Security; -using Newtonsoft.Json; -using Umbraco.Core.Persistence.DatabaseModelDefinitions; -using Umbraco.Core.Security; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_7_0 -{ - public class UpdateUserTables : MigrationBase - { - public UpdateUserTables(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - //Don't execute if the column is already there - var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); - - if (columns.Any(x => x.TableName.InvariantEquals("umbracoUser") && x.ColumnName.InvariantEquals("createDate")) == false) - Create.Column("createDate").OnTable("umbracoUser").AsDateTime().NotNullable().WithDefault(SystemMethods.CurrentDateTime).Do(); - - if (columns.Any(x => x.TableName.InvariantEquals("umbracoUser") && x.ColumnName.InvariantEquals("updateDate")) == false) - Create.Column("updateDate").OnTable("umbracoUser").AsDateTime().NotNullable().WithDefault(SystemMethods.CurrentDateTime).Do(); - - if (columns.Any(x => x.TableName.InvariantEquals("umbracoUser") && x.ColumnName.InvariantEquals("emailConfirmedDate")) == false) - Create.Column("emailConfirmedDate").OnTable("umbracoUser").AsDateTime().Nullable().Do(); - - if (columns.Any(x => x.TableName.InvariantEquals("umbracoUser") && x.ColumnName.InvariantEquals("invitedDate")) == false) - Create.Column("invitedDate").OnTable("umbracoUser").AsDateTime().Nullable().Do(); - - if (columns.Any(x => x.TableName.InvariantEquals("umbracoUser") && x.ColumnName.InvariantEquals("avatar")) == false) - Create.Column("avatar").OnTable("umbracoUser").AsString(500).Nullable().Do(); - - if (columns.Any(x => x.TableName.InvariantEquals("umbracoUser") && x.ColumnName.InvariantEquals("passwordConfig")) == false) - { - Create.Column("passwordConfig").OnTable("umbracoUser").AsString(500).Nullable().Do(); - //Check if we have a known config, we only want to store config for hashing - var membershipProvider = MembershipProviderExtensions.GetUsersMembershipProvider(); - if (membershipProvider.PasswordFormat == MembershipPasswordFormat.Hashed) - { - var json = JsonConvert.SerializeObject(new { hashAlgorithm = Membership.HashAlgorithmType }); - Database.Execute("UPDATE umbracoUser SET passwordConfig = '" + json + "'"); - } - } - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddIndexToPropertyTypeAliasColumn.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddIndexToPropertyTypeAliasColumn.cs deleted file mode 100644 index ddb084a609..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddIndexToPropertyTypeAliasColumn.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Linq; -using Umbraco.Core.Persistence.SqlSyntax; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_8_0 -{ - internal class AddIndexToPropertyTypeAliasColumn : MigrationBase - { - public AddIndexToPropertyTypeAliasColumn(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var dbIndexes = SqlSyntax.GetDefinedIndexesDefinitions(Context.Database); - - //make sure it doesn't already exist - if (dbIndexes.Any(x => x.IndexName.InvariantEquals("IX_cmsPropertyTypeAlias")) == false) - { - //we can apply the index - Create.Index("IX_cmsPropertyTypeAlias").OnTable(Constants.DatabaseSchema.Tables.PropertyType) - .OnColumn("Alias") - .Ascending().WithOptions().NonClustered() - .Do(); - } - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddInstructionCountColumn.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddInstructionCountColumn.cs deleted file mode 100644 index 0ce2c91f2e..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddInstructionCountColumn.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Linq; -using Umbraco.Core.Persistence.Dtos; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_8_0 -{ - internal class AddInstructionCountColumn : MigrationBase - { - public AddInstructionCountColumn(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); - - if (columns.Any(x => x.TableName.InvariantEquals(Constants.DatabaseSchema.Tables.CacheInstruction) && x.ColumnName.InvariantEquals("instructionCount")) == false) - AddColumn("instructionCount"); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddMediaVersionTable.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddMediaVersionTable.cs deleted file mode 100644 index b4c0062770..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddMediaVersionTable.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Dtos; -using Umbraco.Core.Persistence.Factories; -using static Umbraco.Core.Persistence.NPocoSqlExtensions.Statics; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_8_0 -{ - internal class AddMediaVersionTable : MigrationBase - { - public AddMediaVersionTable(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var tables = SqlSyntax.GetTablesInSchema(Context.Database).ToArray(); - - if (tables.InvariantContains(Constants.DatabaseSchema.Tables.MediaVersion)) return; - - Create.Table().Do(); - MigrateMediaPaths(); - } - - private void MigrateMediaPaths() - { - // this may not be the most efficient way to do it, compared to how it's done in v7, but this - // migration should only run for v8 sites that are being developed, before v8 is released, so - // no big sites and performances don't matter here - keep it simple - - var sql = Sql() - .Select(x => x.VarcharValue, x => x.TextValue) - .AndSelect(x => Alias(x.Id, "versionId")) - .From() - .InnerJoin().On((left, right) => left.PropertyTypeId == right.Id) - .InnerJoin().On((left, right) => left.VersionId == right.Id) - .InnerJoin().On((left, right) => left.NodeId == right.NodeId) - .Where(x => x.Alias == "umbracoFile") - .Where(x => x.NodeObjectType == Constants.ObjectTypes.Media); - - var paths = new List(); - - //using QUERY = a db cursor, we won't load this all into memory first, just row by row - foreach (var row in Database.Query(sql)) - { - // if there's values then ensure there's a media path match and extract it - string mediaPath = null; - if ( - (row.varcharValue != null && ContentBaseFactory.TryMatch((string) row.varcharValue, out mediaPath)) - || (row.textValue != null && ContentBaseFactory.TryMatch((string) row.textValue, out mediaPath))) - { - paths.Add(new MediaVersionDto - { - Id = (int) row.versionId, - Path = mediaPath - }); - } - } - - // bulk insert - Database.BulkInsertRecords(paths); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddTourDataUserColumn.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddTourDataUserColumn.cs deleted file mode 100644 index cd2678205f..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddTourDataUserColumn.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Linq; -using Umbraco.Core.Persistence.DatabaseAnnotations; -using Umbraco.Core.Persistence.Dtos; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_8_0 -{ - internal class AddTourDataUserColumn : MigrationBase - { - public AddTourDataUserColumn(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); - - if (columns.Any(x => x.TableName.InvariantEquals(Constants.DatabaseSchema.Tables.User) && x.ColumnName.InvariantEquals("tourData")) == false) - AddColumn("tourData"); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddUserLoginTable.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddUserLoginTable.cs deleted file mode 100644 index 7a55362072..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_8_0/AddUserLoginTable.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Linq; -using Umbraco.Core.Persistence.Dtos; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_8_0 -{ - internal class AddUserLoginTable : MigrationBase - { - public AddUserLoginTable(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var tables = SqlSyntax.GetTablesInSchema(Context.Database).ToArray(); - - if (tables.InvariantContains(Constants.DatabaseSchema.Tables.UserLogin) == false) - { - Create.Table().Do(); - } - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_9_0/AddIsSensitiveMemberTypeColumn.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_9_0/AddIsSensitiveMemberTypeColumn.cs deleted file mode 100644 index 2b5f481769..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_9_0/AddIsSensitiveMemberTypeColumn.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Linq; -using Umbraco.Core.Persistence.Dtos; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_9_0 -{ - internal class AddIsSensitiveMemberTypeColumn : MigrationBase - { - public AddIsSensitiveMemberTypeColumn(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); - - if (columns.Any(x => x.TableName.InvariantEquals(Constants.DatabaseSchema.Tables.MemberPropertyType) && x.ColumnName.InvariantEquals("isSensitive")) == false) - AddColumn("isSensitive"); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_9_0/AddUmbracoAuditTable.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_9_0/AddUmbracoAuditTable.cs deleted file mode 100644 index e7880dfc73..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_9_0/AddUmbracoAuditTable.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Linq; -using Umbraco.Core.Persistence.Dtos; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_9_0 -{ - internal class AddUmbracoAuditTable : MigrationBase - { - public AddUmbracoAuditTable(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var tables = SqlSyntax.GetTablesInSchema(Context.Database).ToArray(); - - if (tables.InvariantContains(Constants.DatabaseSchema.Tables.AuditEntry)) - return; - - Create.Table().Do(); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_9_0/AddUmbracoConsentTable.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_9_0/AddUmbracoConsentTable.cs deleted file mode 100644 index e3656f69ac..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_9_0/AddUmbracoConsentTable.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Linq; -using Umbraco.Core.Persistence.Dtos; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_9_0 -{ - internal class AddUmbracoConsentTable : MigrationBase - { - public AddUmbracoConsentTable(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var tables = SqlSyntax.GetTablesInSchema(Context.Database).ToArray(); - - if (tables.InvariantContains(Constants.DatabaseSchema.Tables.Consent)) - return; - - Create.Table().Do(); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_7_9_0/CreateSensitiveDataUserGroup.cs b/src/Umbraco.Core/Migrations/Upgrade/V_7_9_0/CreateSensitiveDataUserGroup.cs deleted file mode 100644 index ce656aa0c1..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_7_9_0/CreateSensitiveDataUserGroup.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Dtos; - -namespace Umbraco.Core.Migrations.Upgrade.V_7_9_0 -{ - internal class CreateSensitiveDataUserGroup : MigrationBase - { - public CreateSensitiveDataUserGroup(IMigrationContext context) - : base(context) - { } - - public override void Migrate() - { - var sql = Sql() - .SelectCount() - .From() - .Where(x => x.Alias == Constants.Security.SensitiveDataGroupAlias); - - var exists = Database.ExecuteScalar(sql) > 0; - if (exists) return; - - var groupId = Database.Insert(Constants.DatabaseSchema.Tables.UserGroup, "id", new UserGroupDto { StartMediaId = -1, StartContentId = -1, Alias = Constants.Security.SensitiveDataGroupAlias, Name = "Sensitive data", DefaultPermissions = "", CreateDate = DateTime.Now, UpdateDate = DateTime.Now, Icon = "icon-lock" }); - Database.Insert(new User2UserGroupDto { UserGroupId = Convert.ToInt32(groupId), UserId = Constants.Security.SuperUserId }); // add super to sensitive data - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_1_0/ChangeNuCacheJsonFormat.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_1_0/ChangeNuCacheJsonFormat.cs deleted file mode 100644 index 0ceb366e1c..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_1_0/ChangeNuCacheJsonFormat.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Umbraco.Core.Migrations.PostMigrations; - -namespace Umbraco.Core.Migrations.Upgrade.V_8_1_0 -{ - public class ChangeNuCacheJsonFormat : MigrationBase - { - public ChangeNuCacheJsonFormat(IMigrationContext context) : base(context) - { } - - public override void Migrate() - { - // nothing - just adding the post-migration - Context.AddPostMigration(); - } - } -} diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 8eeb8773ea..cb5448a92c 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -386,22 +386,6 @@ - - - - - - - - - - - - - - - - @@ -1138,30 +1122,8 @@ - - - - - - - - - - - - - - - - - - - - - - From 7cd31ce970106520b65f7412f5ffb42f5a7e41ac Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 7 May 2019 14:51:34 +0200 Subject: [PATCH 13/82] Fix TourController during upgrade --- src/Umbraco.Web/Editors/TourController.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Editors/TourController.cs b/src/Umbraco.Web/Editors/TourController.cs index a61926740a..166e5a894d 100644 --- a/src/Umbraco.Web/Editors/TourController.cs +++ b/src/Umbraco.Web/Editors/TourController.cs @@ -30,6 +30,10 @@ namespace Umbraco.Web.Editors if (Current.Configs.Settings().BackOffice.Tours.EnableTours == false) return result; + var user = Composing.Current.UmbracoContext.Security.CurrentUser; + if (user == null) + return result; + //get all filters that will be applied to all tour aliases var aliasOnlyFilters = _filters.Where(x => x.PluginName == null && x.TourFileName == null).ToList(); @@ -71,7 +75,7 @@ namespace Umbraco.Web.Editors } } //Get all allowed sections for the current user - var allowedSections = Composing.Current.UmbracoContext.Security.CurrentUser.AllowedSections.ToList(); + var allowedSections = user.AllowedSections.ToList(); var toursToBeRemoved = new List(); From 58cdff1d715e4207eb3d828d980248d53b10f757 Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Wed, 8 May 2019 11:09:45 +0100 Subject: [PATCH 14/82] Removed preload from HSTS header --- src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs b/src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs index 18827b0c81..570dc493a9 100644 --- a/src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs +++ b/src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs @@ -16,7 +16,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Security // If you want do to it perfectly, you have to submit it https://hstspreload.appspot.com/, // but then you should include subdomains and I wouldn't suggest to do that for Umbraco-sites. public HstsCheck(IRuntimeState runtime, ILocalizedTextService textService) - : base(runtime, textService, "Strict-Transport-Security", "max-age=10886400; preload", "hSTS", true) + : base(runtime, textService, "Strict-Transport-Security", "max-age=10886400", "hSTS", true) { } } From dae8802c506fd586a0f8191047b0459380778f4b Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Wed, 8 May 2019 11:11:01 +0100 Subject: [PATCH 15/82] Removed preload from descriptions --- src/Umbraco.Web.UI/Umbraco/config/lang/en.xml | 2 +- src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml | 2 +- src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml | 2 +- src/Umbraco.Web.UI/Umbraco/config/lang/ru.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml index 9678903975..b40da58a2c 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml @@ -2036,7 +2036,7 @@ To manage your website, simply open the Umbraco back office and start adding con A setting to create a header protecting against MIME sniffing vulnerabilities has been added to your web.config file. Strict-Transport-Security, also known as the HSTS-header, was found.]]> Strict-Transport-Security was not found.]]> - Adds the header 'Strict-Transport-Security' with the value 'max-age=10886400; preload' to the httpProtocol/customHeaders section of web.config. Use this fix only if you will have your domains running with https for the next 18 weeks (minimum). + Adds the header 'Strict-Transport-Security' with the value 'max-age=10886400' to the httpProtocol/customHeaders section of web.config. Use this fix only if you will have your domains running with https for the next 18 weeks (minimum). The HSTS header has been added to your web.config file. X-XSS-Protection was found.]]> X-XSS-Protection was not found.]]> diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml index af6add9f64..bd2cc6f5a2 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml @@ -2050,7 +2050,7 @@ To manage your website, simply open the Umbraco back office and start adding con A setting to create a header protecting against MIME sniffing vulnerabilities has been added to your web.config file. Strict-Transport-Security, also known as the HSTS-header, was found.]]> Strict-Transport-Security was not found.]]> - Adds the header 'Strict-Transport-Security' with the value 'max-age=10886400; preload' to the httpProtocol/customHeaders section of web.config. Use this fix only if you will have your domains running with https for the next 18 weeks (minimum). + Adds the header 'Strict-Transport-Security' with the value 'max-age=10886400' to the httpProtocol/customHeaders section of web.config. Use this fix only if you will have your domains running with https for the next 18 weeks (minimum). The HSTS header has been added to your web.config file. X-XSS-Protection was found.]]> X-XSS-Protection was not found.]]> diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml index 8e378f0bc9..8bc41d63b2 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/fr.xml @@ -1813,7 +1813,7 @@ Pour gérer votre site, ouvrez simplement le backoffice Umbraco et commencez à Une configuration a été ajoutée dans votre fichier web.config pour créer un header protégeant contre les vulnérabilités de MIME sniffing. Strict-Transport-Security, aussi connu sous le nom de HSTS-header, a été trouvé.]]> Strict-Transport-Security, aussi connu sous le nom de HSTS-header, n'a pas été trouvé.]]> - Ajoute l'en-tête 'Strict-Transport-Security' avec la valeur 'max-age=10886400; preload' à la section httpProtocol/customHeaders du fichier web.config. Utilisez cette correction uniquement si vos domaines vont fonctionner en https pour les 18 prochaines semaines (minimum). + Ajoute l'en-tête 'Strict-Transport-Security' avec la valeur 'max-age=10886400' à la section httpProtocol/customHeaders du fichier web.config. Utilisez cette correction uniquement si vos domaines vont fonctionner en https pour les 18 prochaines semaines (minimum). L'en-tête HSTS a été ajouté dans votre fichier web.config. X-XSS-Protection a été trouvé.]]> X-XSS-Protection n'a pas été trouvé.]]> diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/ru.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/ru.xml index 7698453b4a..5f138efc81 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/ru.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/ru.xml @@ -743,7 +743,7 @@ Значение, добавляющее заголовок, препятствующий использованию MIME-уязвимостей, успешно добавлено в файл web.config. Strict-Transport-Security, известный также как HSTS-header, обнаружен.]]> Strict-Transport-Security не найден.]]> - Добавляет заголовок 'Strict-Transport-Security' и его значение 'max-age=10886400; preload' в секцию httpProtocol/customHeaders файла web.config. Применяйте этот способ только в случае, если доступ к Вашим сайтам будет осуществляться по протоколу https как минимум ближайшие 18 недель. + Добавляет заголовок 'Strict-Transport-Security' и его значение 'max-age=10886400' в секцию httpProtocol/customHeaders файла web.config. Применяйте этот способ только в случае, если доступ к Вашим сайтам будет осуществляться по протоколу https как минимум ближайшие 18 недель. Заголовок HSTS-header успешно добавлен в файл web.config. X-XSS-Protection обнаружен.]]> X-XSS-Protection не найден.]]> From bea1d35ebff9ff08f6d2a06e3b1b0dd3fee248ea Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Wed, 8 May 2019 11:11:47 +0100 Subject: [PATCH 16/82] Updated hsts urls --- src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs b/src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs index 570dc493a9..cb82badc4a 100644 --- a/src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs +++ b/src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs @@ -11,9 +11,9 @@ namespace Umbraco.Web.HealthCheck.Checks.Security public class HstsCheck : BaseHttpHeaderCheck { // The check is mostly based on the instructions in the OWASP CheatSheet - // (https://www.owasp.org/index.php/HTTP_Strict_Transport_Security_Cheat_Sheet) + // (https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/HTTP_Strict_Transport_Security_Cheat_Sheet.md) // and the blog post of Troy Hunt (https://www.troyhunt.com/understanding-http-strict-transport/) - // If you want do to it perfectly, you have to submit it https://hstspreload.appspot.com/, + // If you want do to it perfectly, you have to submit it https://hstspreload.org/, // but then you should include subdomains and I wouldn't suggest to do that for Umbraco-sites. public HstsCheck(IRuntimeState runtime, ILocalizedTextService textService) : base(runtime, textService, "Strict-Transport-Security", "max-age=10886400", "hSTS", true) From b6ad19ccad3360b6eb30ef10307f08e0b8f2807f Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Wed, 8 May 2019 11:12:09 +0100 Subject: [PATCH 17/82] Corrected hsts max age description --- src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs b/src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs index cb82badc4a..eb4a3d4388 100644 --- a/src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs +++ b/src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs @@ -6,7 +6,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Security [HealthCheck( "E2048C48-21C5-4BE1-A80B-8062162DF124", "Cookie hijacking and protocol downgrade attacks Protection (Strict-Transport-Security Header (HSTS))", - Description = "Checks if your site, when running with HTTPS, contains the Strict-Transport-Security Header (HSTS). If not, it adds with a default of 100 days.", + Description = "Checks if your site, when running with HTTPS, contains the Strict-Transport-Security Header (HSTS). If not, it adds with a default of 126 days.", Group = "Security")] public class HstsCheck : BaseHttpHeaderCheck { From 0a752c8985620b057cd2b1f495cf1542e1b722c6 Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Wed, 8 May 2019 11:57:03 +0100 Subject: [PATCH 18/82] Updated hsts description from days to weeks --- src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs b/src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs index eb4a3d4388..d0da243ced 100644 --- a/src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs +++ b/src/Umbraco.Web/HealthCheck/Checks/Security/HstsCheck.cs @@ -6,7 +6,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Security [HealthCheck( "E2048C48-21C5-4BE1-A80B-8062162DF124", "Cookie hijacking and protocol downgrade attacks Protection (Strict-Transport-Security Header (HSTS))", - Description = "Checks if your site, when running with HTTPS, contains the Strict-Transport-Security Header (HSTS). If not, it adds with a default of 126 days.", + Description = "Checks if your site, when running with HTTPS, contains the Strict-Transport-Security Header (HSTS). If not, it adds with a default of 18 weeks.", Group = "Security")] public class HstsCheck : BaseHttpHeaderCheck { From e958ca6f89f03795d5faf39ff960eae11ffb198f Mon Sep 17 00:00:00 2001 From: leekelleher Date: Thu, 9 May 2019 07:21:18 +0100 Subject: [PATCH 19/82] Fixed `EntityController.ConvertToObjectType` (for MemberType) When the `entityType` was "MemberType", it would return the "MediaType" object-type. --- src/Umbraco.Web/Editors/EntityController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Editors/EntityController.cs b/src/Umbraco.Web/Editors/EntityController.cs index 05f7b6525c..082469f690 100644 --- a/src/Umbraco.Web/Editors/EntityController.cs +++ b/src/Umbraco.Web/Editors/EntityController.cs @@ -893,7 +893,7 @@ namespace Umbraco.Web.Editors case UmbracoEntityTypes.Media: return UmbracoObjectTypes.Media; case UmbracoEntityTypes.MemberType: - return UmbracoObjectTypes.MediaType; + return UmbracoObjectTypes.MemberType; case UmbracoEntityTypes.MemberGroup: return UmbracoObjectTypes.MemberGroup; case UmbracoEntityTypes.MediaType: From 943e050493ccb9a3fcb84813bb1f39986753d8b5 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Thu, 9 May 2019 09:45:29 +0200 Subject: [PATCH 20/82] Fix noPasswordManager name for docs Fix `noPasswordManager` for documentation. https://our.umbraco.com/apidocs/v8/ui/#/api/umbraco.directives.directive:no-password-manager --- .../src/common/directives/util/noPasswordManager.directive.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/util/noPasswordManager.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/util/noPasswordManager.directive.js index 190c504aa6..2c52506f42 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/util/noPasswordManager.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/util/noPasswordManager.directive.js @@ -1,6 +1,6 @@ /** * @ngdoc directive -* @name umbraco.directives.directive:no-password-manager +* @name umbraco.directives.directive:noPasswordManager * @attribte * @function * @description From 62a6a4ec92308346438493112333d797b71cb6c7 Mon Sep 17 00:00:00 2001 From: Arnold Visser Date: Thu, 9 May 2019 10:31:44 +0200 Subject: [PATCH 21/82] 5420: v8 Invited user keeps showing as "has not logged in yet" --- src/Umbraco.Web/Editors/CurrentUserController.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Umbraco.Web/Editors/CurrentUserController.cs b/src/Umbraco.Web/Editors/CurrentUserController.cs index 3c8aed247e..46151f2a9e 100644 --- a/src/Umbraco.Web/Editors/CurrentUserController.cs +++ b/src/Umbraco.Web/Editors/CurrentUserController.cs @@ -135,6 +135,8 @@ namespace Umbraco.Web.Editors //They've successfully set their password, we can now update their user account to be approved Security.CurrentUser.IsApproved = true; + //They've successfully set their password, and will now get fully logged into the back office, so the lastlogindate is set so the backoffice shows they have logged in + Security.CurrentUser.LastLoginDate = DateTime.UtcNow; Services.UserService.Save(Security.CurrentUser); //now we can return their full object since they are now really logged into the back office From a1828fec51c9f7ea698955aca16c3251c58b7e65 Mon Sep 17 00:00:00 2001 From: Stephan Date: Wed, 4 Jul 2018 15:07:54 +0200 Subject: [PATCH 22/82] Fix migrations --- .../CreateKeysAndIndexesBuilder.cs | 22 +++++++++++++++++++ src/Umbraco.Core/Migrations/MigrationPlan.cs | 7 ++++++ .../Upgrade/Post/CreateKeysAndIndexes.cs | 21 ++++++++++++++++++ .../Upgrade/V_8_0_0/AddVariationTables2.cs | 17 ++++++++++++++ .../Upgrade/V_8_0_0/DataTypeMigration.cs | 12 ++++------ .../Upgrade/V_8_0_0/TagsMigration.cs | 11 ++++++---- .../Upgrade/V_8_0_0/VariantsMigration.cs | 6 ++--- src/Umbraco.Core/Umbraco.Core.csproj | 1 + 8 files changed, 81 insertions(+), 16 deletions(-) create mode 100644 src/Umbraco.Core/Migrations/Upgrade/Post/CreateKeysAndIndexes.cs diff --git a/src/Umbraco.Core/Migrations/Expressions/Create/KeysAndIndexes/CreateKeysAndIndexesBuilder.cs b/src/Umbraco.Core/Migrations/Expressions/Create/KeysAndIndexes/CreateKeysAndIndexesBuilder.cs index b11ef7e2c8..1cb55c1a51 100644 --- a/src/Umbraco.Core/Migrations/Expressions/Create/KeysAndIndexes/CreateKeysAndIndexesBuilder.cs +++ b/src/Umbraco.Core/Migrations/Expressions/Create/KeysAndIndexes/CreateKeysAndIndexesBuilder.cs @@ -3,6 +3,8 @@ using NPoco; using Umbraco.Core.Migrations.Expressions.Common; using Umbraco.Core.Migrations.Expressions.Execute.Expressions; using Umbraco.Core.Persistence.DatabaseModelDefinitions; +using Umbraco.Core.Composing; +using Umbraco.Core.Logging; namespace Umbraco.Core.Migrations.Expressions.Create.KeysAndIndexes { @@ -25,6 +27,26 @@ namespace Umbraco.Core.Migrations.Expressions.Create.KeysAndIndexes var syntax = _context.SqlContext.SqlSyntax; var tableDefinition = DefinitionFactory.GetTableDefinition(TypeOfDto, syntax); + // fixme + //var exists = _context.SqlContext.SqlSyntax.DoesTableExist(_context.Database, tableDefinition.Name); + //if (!exists) return; // no point creating keys and indexes on non-existing table + + //// problem: this is going to create the keys and constraints, + //// using the 'latest' table names - but if we do it in a migration, + //// and later on rename a table, we are going to try to create keys + //// and constraints referencing the new table name, ie something + //// that does not exist yet! + //// + //// fixme should we also NOT create those that already exist? + // or, completely prevent removing ALL keys? + // but even on 1 table, if we remove keys, we may not be able to recreate them all + // and then... Create.Table is always going to fail? need to use it with COPIES of the DTO class! + // so that it tries to create things that make sense _at the time it runs_ + // + // eg the new PropertyData points to new DataType that does not exist yet + // because... we should have kept a PropertyData that points to... a DataType = TWO dtos! + // so basically, keep a 'graveyard' of old dtos? for migrations only? + ExecuteSql(syntax.FormatPrimaryKey(tableDefinition)); foreach (var sql in syntax.Format(tableDefinition.Indexes)) ExecuteSql(sql); diff --git a/src/Umbraco.Core/Migrations/MigrationPlan.cs b/src/Umbraco.Core/Migrations/MigrationPlan.cs index 321bfac34b..2f475a9b45 100644 --- a/src/Umbraco.Core/Migrations/MigrationPlan.cs +++ b/src/Umbraco.Core/Migrations/MigrationPlan.cs @@ -328,6 +328,13 @@ namespace Umbraco.Core.Migrations postMigration.Migrate(); } + foreach (var postMigrationType in context.PostMigrations) + { + logger.Info($"Post: {postMigrationType.FullName}."); + var migration = migrationBuilder.Build(postMigrationType, context); + migration.Migrate(); + } + logger.Info("Done (pending scope completion)."); // safety check diff --git a/src/Umbraco.Core/Migrations/Upgrade/Post/CreateKeysAndIndexes.cs b/src/Umbraco.Core/Migrations/Upgrade/Post/CreateKeysAndIndexes.cs new file mode 100644 index 0000000000..1ca0c13baf --- /dev/null +++ b/src/Umbraco.Core/Migrations/Upgrade/Post/CreateKeysAndIndexes.cs @@ -0,0 +1,21 @@ +using Umbraco.Core.Migrations.Install; + +namespace Umbraco.Core.Migrations.Upgrade.Post +{ + public class CreateKeysAndIndexes : MigrationBase + { + public CreateKeysAndIndexes(IMigrationContext context) + : base(context) + { } + + public override void Migrate() + { + // really make sure there is nothing left + Delete.KeysAndIndexes().Do(); + + // re-create *all* keys and indexes + foreach (var x in DatabaseSchemaCreator.OrderedTables) + Create.KeysAndIndexes(x).Do(); + } + } +} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddVariationTables2.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddVariationTables2.cs index c6cad2eac1..be5f2d9cfb 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddVariationTables2.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddVariationTables2.cs @@ -11,8 +11,25 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0 public override void Migrate() { + // fixme + Create.KeysAndIndexes().Do(); + Create.KeysAndIndexes().Do(); + Create.KeysAndIndexes().Do(); + Create.KeysAndIndexes().Do(); + Create.KeysAndIndexes().Do(); + Create.Table().Do(); Create.Table().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(); + } } } diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DataTypeMigration.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DataTypeMigration.cs index d7180385f0..43b2015bd2 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DataTypeMigration.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DataTypeMigration.cs @@ -1,10 +1,8 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using Newtonsoft.Json; using NPoco; -using Umbraco.Core.Migrations.Install; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Dtos; using Umbraco.Core.Persistence.Querying; @@ -22,6 +20,8 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0 { // 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(); @@ -31,16 +31,12 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0 // create column AddColumn(Constants.DatabaseSchema.Tables.DataType, "config"); - Execute.Sql(Sql().Update(u => u.Set(x => x.Configuration, string.Empty)).SQL).Do(); - - // re-create *all* keys and indexes - foreach (var x in DatabaseSchemaCreator.OrderedTables) - Create.KeysAndIndexes(x).Do(); + Execute.Sql(Sql().Update(u => u.Set(x => x.Configuration, string.Empty))).Do(); // renames Execute.Sql(Sql() .Update(u => u.Set(x => x.EditorAlias, "Umbraco.ColorPicker")) - .Where(x => x.EditorAlias == "Umbraco.ColorPickerAlias").SQL).Do(); + .Where(x => x.EditorAlias == "Umbraco.ColorPickerAlias")).Do(); // from preValues to configuration... var sql = Sql() diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/TagsMigration.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/TagsMigration.cs index 5dc5e0b6fe..c93e81fc01 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/TagsMigration.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/TagsMigration.cs @@ -1,4 +1,5 @@ -using Umbraco.Core.Persistence.Dtos; +using System.Linq; +using Umbraco.Core.Persistence.Dtos; namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0 { @@ -17,10 +18,12 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0 //AddColumn(Constants.DatabaseSchema.Tables.Tag, "key"); // kill unused parentId column - Delete.ForeignKey("FK_cmsTags_cmsTags").OnTable(Constants.DatabaseSchema.Tables.Tag).Do(); + 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(); } } - - // fixes TagsMigration that... originally failed to properly drop the ParentId column } diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/VariantsMigration.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/VariantsMigration.cs index c193fdeb1f..2732913f2a 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/VariantsMigration.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/VariantsMigration.cs @@ -20,6 +20,8 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0 { // 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(); @@ -46,10 +48,6 @@ HAVING COUNT(v2.id) <> 1").Any()) Debugger.Break(); throw new Exception("Migration failed: missing or duplicate 'current' content versions."); } - - // re-create *all* keys and indexes - foreach (var x in DatabaseSchemaCreator.OrderedTables) - Create.KeysAndIndexes(x).Do(); } private void MigratePropertyData() diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index cb5448a92c..95e1c1de1d 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -416,6 +416,7 @@ + From 7fed43cc68a85f9d3596d821169831111c924f0d Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 7 May 2019 19:28:51 +0200 Subject: [PATCH 23/82] Fix migration tooling --- .../Expressions/Delete/DeleteBuilder.cs | 7 ++- .../Expressions/Delete/IDeleteBuilder.cs | 2 +- .../DeleteKeysAndIndexesBuilder.cs | 43 +++++++++---------- .../Migrations/IMigrationContext.cs | 2 +- .../Migrations/MigrationContext.cs | 1 + .../Migrations/MigrationExpressionBase.cs | 1 + src/Umbraco.Core/Migrations/MigrationPlan.cs | 9 +--- .../Migrations/AdvancedMigrationTests.cs | 8 +++- 8 files changed, 38 insertions(+), 35 deletions(-) diff --git a/src/Umbraco.Core/Migrations/Expressions/Delete/DeleteBuilder.cs b/src/Umbraco.Core/Migrations/Expressions/Delete/DeleteBuilder.cs index d081305cde..bbf2964fa6 100644 --- a/src/Umbraco.Core/Migrations/Expressions/Delete/DeleteBuilder.cs +++ b/src/Umbraco.Core/Migrations/Expressions/Delete/DeleteBuilder.cs @@ -1,4 +1,5 @@ using NPoco; +using Umbraco.Core.Exceptions; using Umbraco.Core.Migrations.Expressions.Common; using Umbraco.Core.Migrations.Expressions.Delete.Column; using Umbraco.Core.Migrations.Expressions.Delete.Constraint; @@ -29,9 +30,11 @@ namespace Umbraco.Core.Migrations.Expressions.Delete } /// - public IExecutableBuilder KeysAndIndexes(string tableName = null) + public IExecutableBuilder KeysAndIndexes(string tableName, bool pk = true, bool fk = true, bool ix = true) { - return new DeleteKeysAndIndexesBuilder(_context) { TableName = tableName }; + if (tableName.IsNullOrWhiteSpace()) + throw new ArgumentNullOrEmptyException(nameof(tableName)); + return new DeleteKeysAndIndexesBuilder(_context) { TableName = tableName, DeletePrimaryKey = pk, DeleteForeignKeys = fk, DeleteIndexes = ix}; } /// diff --git a/src/Umbraco.Core/Migrations/Expressions/Delete/IDeleteBuilder.cs b/src/Umbraco.Core/Migrations/Expressions/Delete/IDeleteBuilder.cs index 07faf5028e..ab5b05a21d 100644 --- a/src/Umbraco.Core/Migrations/Expressions/Delete/IDeleteBuilder.cs +++ b/src/Umbraco.Core/Migrations/Expressions/Delete/IDeleteBuilder.cs @@ -21,7 +21,7 @@ namespace Umbraco.Core.Migrations.Expressions.Delete /// /// Specifies the table to delete keys and indexes for. /// - IExecutableBuilder KeysAndIndexes(string tableName = null); + IExecutableBuilder KeysAndIndexes(string tableName, bool pk = true, bool fk = true, bool ix = true); /// /// Specifies the column to delete. diff --git a/src/Umbraco.Core/Migrations/Expressions/Delete/KeysAndIndexes/DeleteKeysAndIndexesBuilder.cs b/src/Umbraco.Core/Migrations/Expressions/Delete/KeysAndIndexes/DeleteKeysAndIndexesBuilder.cs index 1c595d9103..b16748c851 100644 --- a/src/Umbraco.Core/Migrations/Expressions/Delete/KeysAndIndexes/DeleteKeysAndIndexesBuilder.cs +++ b/src/Umbraco.Core/Migrations/Expressions/Delete/KeysAndIndexes/DeleteKeysAndIndexesBuilder.cs @@ -18,34 +18,33 @@ namespace Umbraco.Core.Migrations.Expressions.Delete.KeysAndIndexes public string TableName { get; set; } + public bool DeletePrimaryKey { get; set; } + + public bool DeleteForeignKeys { get; set; } + + public bool DeleteIndexes { get; set; } + /// public void Do() { - if (TableName == null) - { - // drop keys - var keys = _context.SqlContext.SqlSyntax.GetConstraintsPerTable(_context.Database).DistinctBy(x => x.Item2).ToArray(); - foreach (var key in keys.Where(x => x.Item2.StartsWith("FK_"))) - Delete.ForeignKey(key.Item2).OnTable(key.Item1).Do(); - foreach (var key in keys.Where(x => x.Item2.StartsWith("PK_"))) - Delete.PrimaryKey(key.Item2).FromTable(key.Item1).Do(); + _context.BuildingExpression = false; - // drop indexes - var indexes = _context.SqlContext.SqlSyntax.GetDefinedIndexesDefinitions(_context.Database).DistinctBy(x => x.IndexName).ToArray(); - foreach (var index in indexes) - Delete.Index(index.IndexName).OnTable(index.TableName).Do(); + // drop keys + if (DeleteForeignKeys || DeletePrimaryKey) + { + var keys = _context.SqlContext.SqlSyntax.GetConstraintsPerTable(_context.Database).DistinctBy(x => x.Item2).ToList(); + if (DeleteForeignKeys) + foreach (var key in keys.Where(x => x.Item1 == TableName && x.Item2.StartsWith("FK_"))) + Delete.ForeignKey(key.Item2).OnTable(key.Item1).Do(); + if (DeletePrimaryKey) + foreach (var key in keys.Where(x => x.Item1 == TableName && x.Item2.StartsWith("PK_"))) + Delete.PrimaryKey(key.Item2).FromTable(key.Item1).Do(); } - else - { - // drop keys - var keys = _context.SqlContext.SqlSyntax.GetConstraintsPerTable(_context.Database).DistinctBy(x => x.Item2).ToArray(); - foreach (var key in keys.Where(x => x.Item1 == TableName && x.Item2.StartsWith("FK_"))) - Delete.ForeignKey(key.Item2).OnTable(key.Item1).Do(); - foreach (var key in keys.Where(x => x.Item1 == TableName && x.Item2.StartsWith("PK_"))) - Delete.PrimaryKey(key.Item2).FromTable(key.Item1).Do(); - // drop indexes - var indexes = _context.SqlContext.SqlSyntax.GetDefinedIndexesDefinitions(_context.Database).DistinctBy(x => x.IndexName).ToArray(); + // drop indexes + if (DeleteIndexes) + { + var indexes = _context.SqlContext.SqlSyntax.GetDefinedIndexesDefinitions(_context.Database).DistinctBy(x => x.IndexName).ToList(); foreach (var index in indexes.Where(x => x.TableName == TableName)) Delete.Index(index.IndexName).OnTable(index.TableName).Do(); } diff --git a/src/Umbraco.Core/Migrations/IMigrationContext.cs b/src/Umbraco.Core/Migrations/IMigrationContext.cs index 2baadc79eb..c76de8dfb3 100644 --- a/src/Umbraco.Core/Migrations/IMigrationContext.cs +++ b/src/Umbraco.Core/Migrations/IMigrationContext.cs @@ -36,7 +36,7 @@ namespace Umbraco.Core.Migrations bool BuildingExpression { get; set; } /// - /// Adds a post-migrations. + /// Adds a post-migration. /// void AddPostMigration() where TMigration : IMigration; diff --git a/src/Umbraco.Core/Migrations/MigrationContext.cs b/src/Umbraco.Core/Migrations/MigrationContext.cs index a8d052036c..0bb2bc11ae 100644 --- a/src/Umbraco.Core/Migrations/MigrationContext.cs +++ b/src/Umbraco.Core/Migrations/MigrationContext.cs @@ -41,6 +41,7 @@ namespace Umbraco.Core.Migrations public void AddPostMigration() where TMigration : IMigration { + // just adding - will be de-duplicated when executing PostMigrations.Add(typeof(TMigration)); } } diff --git a/src/Umbraco.Core/Migrations/MigrationExpressionBase.cs b/src/Umbraco.Core/Migrations/MigrationExpressionBase.cs index 8b5d9cc78c..be06a32ec7 100644 --- a/src/Umbraco.Core/Migrations/MigrationExpressionBase.cs +++ b/src/Umbraco.Core/Migrations/MigrationExpressionBase.cs @@ -92,6 +92,7 @@ namespace Umbraco.Core.Migrations if (_executed) throw new InvalidOperationException("This expression has already been executed."); _executed = true; + Context.BuildingExpression = false; if (sql == null) { diff --git a/src/Umbraco.Core/Migrations/MigrationPlan.cs b/src/Umbraco.Core/Migrations/MigrationPlan.cs index 2f475a9b45..83f4b8640c 100644 --- a/src/Umbraco.Core/Migrations/MigrationPlan.cs +++ b/src/Umbraco.Core/Migrations/MigrationPlan.cs @@ -302,6 +302,8 @@ namespace Umbraco.Core.Migrations while (transition != null) { + logger.Info("Execute {MigrationType}", transition.MigrationType.Name); + var migration = migrationBuilder.Build(transition.MigrationType, context); migration.Migrate(); @@ -328,13 +330,6 @@ namespace Umbraco.Core.Migrations postMigration.Migrate(); } - foreach (var postMigrationType in context.PostMigrations) - { - logger.Info($"Post: {postMigrationType.FullName}."); - var migration = migrationBuilder.Build(postMigrationType, context); - migration.Migrate(); - } - logger.Info("Done (pending scope completion)."); // safety check diff --git a/src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs b/src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs index 5ff0dcffc1..ba5de9dbd3 100644 --- a/src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs +++ b/src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs @@ -217,7 +217,11 @@ namespace Umbraco.Tests.Migrations //Execute.DropKeysAndIndexes("umbracoUser"); // drops *all* tables keys and indexes - Delete.KeysAndIndexes().Do(); + var tables = SqlSyntax.GetTablesInSchema(Context.Database).ToList(); + foreach (var table in tables) + Delete.KeysAndIndexes(table, false).Do(); + foreach (var table in tables) + Delete.KeysAndIndexes(table, true, false, false).Do(); } } @@ -262,7 +266,7 @@ namespace Umbraco.Tests.Migrations public override void Migrate() { // cannot delete the column without this, of course - Delete.KeysAndIndexes().Do(); + Delete.KeysAndIndexes("umbracoUser").Do(); Delete.Column("id").FromTable("umbracoUser").Do(); From ba9aa49b91165e03951c3d3e632e511df0ebb923 Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 7 May 2019 19:44:41 +0200 Subject: [PATCH 24/82] Fix user for v7 migration --- src/Umbraco.Core/Models/Membership/User.cs | 1 - src/Umbraco.Core/Persistence/Factories/UserFactory.cs | 7 +++++++ .../Repositories/Implement/UserRepository.cs | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Models/Membership/User.cs b/src/Umbraco.Core/Models/Membership/User.cs index 2fb293c349..3d071b0a18 100644 --- a/src/Umbraco.Core/Models/Membership/User.cs +++ b/src/Umbraco.Core/Models/Membership/User.cs @@ -54,7 +54,6 @@ namespace Umbraco.Core.Models.Membership _isLockedOut = false; _startContentIds = new int[] { }; _startMediaIds = new int[] { }; - } /// diff --git a/src/Umbraco.Core/Persistence/Factories/UserFactory.cs b/src/Umbraco.Core/Persistence/Factories/UserFactory.cs index dae70d502f..c64eb14bb7 100644 --- a/src/Umbraco.Core/Persistence/Factories/UserFactory.cs +++ b/src/Umbraco.Core/Persistence/Factories/UserFactory.cs @@ -36,6 +36,13 @@ namespace Umbraco.Core.Persistence.Factories user.InvitedDate = dto.InvitedDate; user.TourData = dto.TourData; + // we should never get user with ID zero from database, except + // when upgrading from v7 - mark that user so that we do not + // save it back to database (as that would create a *new* user) + // see also: UserRepository.PersistNewItem + if (dto.Id == 0) + user.AdditionalData["IS_V7_ZERO"] = true; + // reset dirty initial properties (U4-1946) user.ResetDirtyProperties(false); diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs index 9027e9269c..91a20c5bdd 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs @@ -434,6 +434,17 @@ ORDER BY colName"; protected override void PersistNewItem(IUser entity) { + // the use may have no identity, ie ID is zero, and be v7 super + // user - then it has been marked - and we must not persist it + // as new, as we do not want to create a new user - instead, persist + // it as updated + // see also: UserFactory.BuildEntity + if (((User) entity).AdditionalData.ContainsKey("IS_V7_ZERO")) + { + PersistUpdatedItem(entity); + return; + } + ((User) entity).AddingEntity(); // ensure security stamp if missing From 919fb79db9e3116da6833fc77d9bd46c4bb79c74 Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 10 May 2019 08:27:36 +0200 Subject: [PATCH 25/82] Fix migrations --- .../{Post => Common}/CreateKeysAndIndexes.cs | 6 +- .../Upgrade/Common/DeleteKeysAndIndexes.cs | 75 +++++++++++++++++++ .../Migrations/Upgrade/UmbracoPlan.cs | 14 +++- .../Upgrade/V_8_0_0/AddContentNuTable.cs | 45 ++++++----- .../Upgrade/V_8_0_0/AddLockTable.cs | 15 ++-- .../Upgrade/V_8_0_0/AddVariationTables2.cs | 35 +++++---- .../Upgrade/V_8_0_0/DataTypeMigration.cs | 23 ++++-- .../Upgrade/V_8_0_0/DropMigrationsTable.cs | 3 +- .../Upgrade/V_8_0_0/MakeRedirectUrlVariant.cs | 13 ---- .../Upgrade/V_8_0_0/MakeTagsVariant.cs | 11 --- .../Upgrade/V_8_0_0/RefactorXmlColumns.cs | 69 ----------------- .../V_8_0_0/RenameMediaVersionTable.cs | 46 ++++++++++++ .../V_8_0_0/RenameUmbracoDomainsTable.cs | 4 +- .../Migrations/Upgrade/V_8_0_0/SuperZero.cs | 10 ++- .../V_8_0_0/TablesForScheduledPublishing.cs | 2 +- .../Upgrade/V_8_0_0/TagsMigration.cs | 7 -- .../V_8_0_0/UpdatePickerIntegerValuesToUdi.cs | 1 + .../Upgrade/V_8_0_0/UserForeignKeys.cs | 15 +--- .../Upgrade/V_8_0_0/VariantsMigration.cs | 7 +- ...nvertTinyMceAndGridMediaUrlsToLocalLink.cs | 4 +- src/Umbraco.Core/Umbraco.Core.csproj | 5 +- 21 files changed, 224 insertions(+), 186 deletions(-) rename src/Umbraco.Core/Migrations/Upgrade/{Post => Common}/CreateKeysAndIndexes.cs (70%) create mode 100644 src/Umbraco.Core/Migrations/Upgrade/Common/DeleteKeysAndIndexes.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorXmlColumns.cs create mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RenameMediaVersionTable.cs diff --git a/src/Umbraco.Core/Migrations/Upgrade/Post/CreateKeysAndIndexes.cs b/src/Umbraco.Core/Migrations/Upgrade/Common/CreateKeysAndIndexes.cs similarity index 70% rename from src/Umbraco.Core/Migrations/Upgrade/Post/CreateKeysAndIndexes.cs rename to src/Umbraco.Core/Migrations/Upgrade/Common/CreateKeysAndIndexes.cs index 1ca0c13baf..29006c8811 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/Post/CreateKeysAndIndexes.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/Common/CreateKeysAndIndexes.cs @@ -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) diff --git a/src/Umbraco.Core/Migrations/Upgrade/Common/DeleteKeysAndIndexes.cs b/src/Umbraco.Core/Migrations/Upgrade/Common/DeleteKeysAndIndexes.cs new file mode 100644 index 0000000000..b62d492348 --- /dev/null +++ b/src/Umbraco.Core/Migrations/Upgrade/Common/DeleteKeysAndIndexes.cs @@ -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(); + } + } +} diff --git a/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs b/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs index ac0f355447..f0bc816bd7 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs @@ -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("{B36B9ABD-374E-465B-9C5F-26AB0D39326F}"); + To("{7C447271-CA3F-4A6A-A913-5D77015655CB}"); - To("{CBFF58A2-7B50-4F75-8E98-249920DB0F37}"); - To("{3D18920C-E84D-405C-A06A-B7CEE52FE5DD}"); + To("{CBFF58A2-7B50-4F75-8E98-249920DB0F37}"); // fixme cascade + //To("{3D18920C-E84D-405C-A06A-B7CEE52FE5DD}"); // we're going to drop them anyways + To("{5CB66059-45F4-48BA-BCBD-C5035D79206B}"); To("{FB0A5429-587E-4BD0-8A67-20F0E7E62FF7}"); To("{F0C42457-6A3B-4912-A7EA-F27ED85A2092}"); To("{8640C9E4-A1C0-4C59-99BB-609B4E604981}"); @@ -113,14 +117,14 @@ namespace Umbraco.Core.Migrations.Upgrade To("{5F4597F4-A4E0-4AFE-90B5-6D2F896830EB}"); To("{290C18EE-B3DE-4769-84F1-1F467F3F76DA}"); To("{6A2C7C1B-A9DB-4EA9-B6AB-78E7D5B722A7}"); - To("{77874C77-93E5-4488-A404-A630907CEEF0}"); + //To("{77874C77-93E5-4488-A404-A630907CEEF0}"); // we're going to recreate keys at the end To("{8804D8E8-FE62-4E3A-B8A2-C047C2118C38}"); To("{23275462-446E-44C7-8C2C-3B8C1127B07D}"); To("{6B251841-3069-4AD5-8AE9-861F9523E8DA}"); To("{EE429F1B-9B26-43CA-89F8-A86017C809A3}"); To("{08919C4B-B431-449C-90EC-2B8445B5C6B1}"); To("{7EB0254C-CB8B-4C75-B15B-D48C55B449EB}"); - To("{648A2D5F-7467-48F8-B309-E99CEEE00E2A}"); + //To("{648A2D5F-7467-48F8-B309-E99CEEE00E2A}"); // duplicate (see above) To("{C39BF2A7-1454-4047-BBFE-89E40F66ED63}"); To("{64EBCE53-E1F0-463A-B40B-E98EFCCA8AE2}"); To("{0009109C-A0B8-4F3F-8FEB-C137BBDDA268}"); @@ -135,6 +139,8 @@ namespace Umbraco.Core.Migrations.Upgrade .To("{940FD19A-00A8-4D5C-B8FF-939143585726}") .As("{0576E786-5C30-4000-B969-302B61E90CA3}"); + To("{3F9764F5-73D0-4D45-8804-1240A66E43A2}"); + To("{E0CBE54D-A84F-4A8F-9B13-900945FD7ED9}"); To("{78BAF571-90D0-4D28-8175-EF96316DA789}"); // release-8.0.0 To("{80C0A0CB-0DD5-4573-B000-C4B7C313C70D}"); // release-8.0.1 diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddContentNuTable.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddContentNuTable.cs index efa54a0f59..39081bf59e 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddContentNuTable.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddContentNuTable.cs @@ -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(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(); } } } diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddLockTable.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddLockTable.cs index aa14bc81c8..88c6e0bf98 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddLockTable.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddLockTable.cs @@ -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(true); } } } diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddVariationTables2.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddVariationTables2.cs index be5f2d9cfb..473a84d343 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddVariationTables2.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddVariationTables2.cs @@ -11,25 +11,30 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0 public override void Migrate() { - // fixme - Create.KeysAndIndexes().Do(); - Create.KeysAndIndexes().Do(); - Create.KeysAndIndexes().Do(); - Create.KeysAndIndexes().Do(); - Create.KeysAndIndexes().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().Do(); - Create.Table().Do(); + //Create.KeysAndIndexes().Do(); + //Create.KeysAndIndexes().Do(); + //Create.KeysAndIndexes().Do(); + //Create.KeysAndIndexes().Do(); + //Create.KeysAndIndexes().Do(); - Delete.KeysAndIndexes(ContentVersionCultureVariationDto.TableName).Do(); - Delete.KeysAndIndexes(DocumentCultureVariationDto.TableName).Do(); + Create.Table(true).Do(); + Create.Table(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(); } } } diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DataTypeMigration.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DataTypeMigration.cs index 43b2015bd2..3d6b7a647b 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DataTypeMigration.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DataTypeMigration.cs @@ -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); } diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DropMigrationsTable.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DropMigrationsTable.cs index 26668361bd..def6a93400 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DropMigrationsTable.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/DropMigrationsTable.cs @@ -8,7 +8,8 @@ public override void Migrate() { - Delete.Table("umbracoMigration").Do(); + if (TableExists("umbracoMigration")) + Delete.Table("umbracoMigration").Do(); } } } diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/MakeRedirectUrlVariant.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/MakeRedirectUrlVariant.cs index 2e366c7c14..651c95e6bd 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/MakeRedirectUrlVariant.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/MakeRedirectUrlVariant.cs @@ -11,19 +11,6 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0 public override void Migrate() { AddColumn("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(); } } } diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/MakeTagsVariant.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/MakeTagsVariant.cs index 9ccd6d5e76..c898187884 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/MakeTagsVariant.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/MakeTagsVariant.cs @@ -11,17 +11,6 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0 public override void Migrate() { AddColumn("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(); } } } diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorXmlColumns.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorXmlColumns.cs deleted file mode 100644 index c683940f60..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RefactorXmlColumns.cs +++ /dev/null @@ -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(); - 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("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); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RenameMediaVersionTable.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RenameMediaVersionTable.cs new file mode 100644 index 0000000000..b60923fcba --- /dev/null +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RenameMediaVersionTable.cs @@ -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("id", out var sqls); + + // SQLCE does not support UPDATE...FROM + var temp2 = Database.Fetch($@"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("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(); + } + } +} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RenameUmbracoDomainsTable.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RenameUmbracoDomainsTable.cs index 9bbccf368c..0543b57fcc 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RenameUmbracoDomainsTable.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/RenameUmbracoDomainsTable.cs @@ -2,7 +2,9 @@ { public class RenameUmbracoDomainsTable : MigrationBase { - public RenameUmbracoDomainsTable(IMigrationContext context) : base(context) { } + public RenameUmbracoDomainsTable(IMigrationContext context) + : base(context) + { } public override void Migrate() { diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/SuperZero.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/SuperZero.cs index ba29880e79..3f2ba3e31c 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/SuperZero.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/SuperZero.cs @@ -11,20 +11,22 @@ var exists = Database.Fetch("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;"); } diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/TablesForScheduledPublishing.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/TablesForScheduledPublishing.cs index cd4de179bd..70dbe3d29e 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/TablesForScheduledPublishing.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/TablesForScheduledPublishing.cs @@ -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().Do(); + Create.Table(true).Do(); //migrate the schedule foreach(var s in schedules) diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/TagsMigration.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/TagsMigration.cs index c93e81fc01..d6a5380e31 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/TagsMigration.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/TagsMigration.cs @@ -15,14 +15,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0 AlterColumn(Constants.DatabaseSchema.Tables.Tag, "group"); AlterColumn(Constants.DatabaseSchema.Tables.Tag, "tag"); - //AddColumn(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(); } } diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/UpdatePickerIntegerValuesToUdi.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/UpdatePickerIntegerValuesToUdi.cs index 2e37c79632..7f7cf8474c 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/UpdatePickerIntegerValuesToUdi.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/UpdatePickerIntegerValuesToUdi.cs @@ -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; diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/UserForeignKeys.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/UserForeignKeys.cs index 68a68ec53e..f16c9cd761 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/UserForeignKeys.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/UserForeignKeys.cs @@ -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 } - } } diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/VariantsMigration.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/VariantsMigration.cs index 2732913f2a..6b0151723c 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/VariantsMigration.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/VariantsMigration.cs @@ -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 } } diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_1_0/ConvertTinyMceAndGridMediaUrlsToLocalLink.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_1_0/ConvertTinyMceAndGridMediaUrlsToLocalLink.cs index ab8e1cd4d6..bf048bf2bd 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_1_0/ConvertTinyMceAndGridMediaUrlsToLocalLink.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_1_0/ConvertTinyMceAndGridMediaUrlsToLocalLink.cs @@ -26,9 +26,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_1_0 RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); var sqlPropertyData = Sql() - .Select() - .AndSelect() - .AndSelect() + .Select(r => r.Select(x => x.PropertyTypeDto, r1 => r1.Select(x => x.DataTypeDto))) .From() .InnerJoin().On((left, right) => left.PropertyTypeId == right.Id) .InnerJoin().On((left, right) => left.DataTypeId == right.NodeId) diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 95e1c1de1d..7730608f36 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -219,7 +219,9 @@ + + @@ -416,7 +418,7 @@ - + @@ -1124,7 +1126,6 @@ - From 301b16a036ed2e713103fc5015abfbff3bc79f63 Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 10 May 2019 09:06:16 +0200 Subject: [PATCH 26/82] Fix user for v7 migration --- .../Compose/AuditEventsComponent.cs | 5 ++-- .../InstallSteps/SetUmbracoVersionStep.cs | 26 ++++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Core/Compose/AuditEventsComponent.cs b/src/Umbraco.Core/Compose/AuditEventsComponent.cs index 15fdfeacff..e76c13b0fe 100644 --- a/src/Umbraco.Core/Compose/AuditEventsComponent.cs +++ b/src/Umbraco.Core/Compose/AuditEventsComponent.cs @@ -49,9 +49,8 @@ namespace Umbraco.Core.Compose get { var identity = Thread.CurrentPrincipal?.GetUmbracoIdentity(); - return identity == null - ? new User { Id = 0, Name = "SYSTEM", Email = "" } - : _userService.GetUserById(Convert.ToInt32(identity.Id)); + var user = identity == null ? null : _userService.GetUserById(Convert.ToInt32(identity.Id)); + return user ?? new User { Id = 0, Name = "SYSTEM", Email = "" }; } } diff --git a/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs b/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs index c1268ca675..b5fdea32b7 100644 --- a/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs +++ b/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs @@ -34,18 +34,32 @@ namespace Umbraco.Web.Install.InstallSteps public override Task ExecuteAsync(object model) { - //During a new install we'll log the default user in (which is id = 0). - // During an upgrade, the user will already need to be logged in order to run the installer. - var security = new WebSecurity(_httpContext, _userService, _globalSettings); - //we do this check here because for upgrades the user will already be logged in, for brand new installs, - // they will not be logged in, however we cannot check the current installation status because it will tell - // us that it is in 'upgrade' because we already have a database conn configured and a database. + if (security.IsAuthenticated() == false && _globalSettings.ConfigurationStatus.IsNullOrWhiteSpace()) { security.PerformLogin(-1); } + if (security.IsAuthenticated()) + { + // when a user is already logged in, we need to check whether it's user 'zero' + // which is the legacy super user from v7 - and then we need to actually log the + // true super user in - but before that we need to log off, else audit events + // will try to reference user zero and fail + var userIdAttempt = security.GetUserId(); + if (userIdAttempt && userIdAttempt.Result == 0) + { + security.ClearCurrentLogin(); + security.PerformLogin(Constants.Security.SuperUserId); + } + } + else if (_globalSettings.ConfigurationStatus.IsNullOrWhiteSpace()) + { + // for installs, we need to log the super user in + security.PerformLogin(Constants.Security.SuperUserId); + } + // Update configurationStatus _globalSettings.ConfigurationStatus = UmbracoVersion.SemanticVersion.ToSemanticString(); From 0b924f75d46684fe541ca5695ecd990fa6e027fd Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 10 May 2019 10:13:23 +0200 Subject: [PATCH 27/82] Fix migrations --- .../Migrations/Upgrade/UmbracoPlan.cs | 19 ++++++---- .../Upgrade/V_8_0_0/AddLockTable.cs | 21 ----------- .../V_8_0_0/AddUserLoginDtoDateIndex.cs | 22 ------------ .../V_8_0_0/FixLanguageIsoCodeLength.cs | 21 +++++++++++ .../Upgrade/V_8_0_0/FixLockTablePrimaryKey.cs | 23 ------------ .../V_8_1_0/RenameUserLoginDtoDateIndex.cs | 36 +++++++++++++++++++ .../Persistence/Dtos/UserLoginDto.cs | 2 +- src/Umbraco.Core/Umbraco.Core.csproj | 5 ++- 8 files changed, 73 insertions(+), 76 deletions(-) delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddLockTable.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddUserLoginDtoDateIndex.cs create mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/FixLanguageIsoCodeLength.cs delete mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/FixLockTablePrimaryKey.cs create mode 100644 src/Umbraco.Core/Migrations/Upgrade/V_8_1_0/RenameUserLoginDtoDateIndex.cs diff --git a/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs b/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs index f0bc816bd7..19a45a3b22 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs @@ -90,11 +90,11 @@ namespace Umbraco.Core.Migrations.Upgrade // From("{init-7.14.0}"); + // begin migrating from v7 - remove all keys and indexes To("{B36B9ABD-374E-465B-9C5F-26AB0D39326F}"); To("{7C447271-CA3F-4A6A-A913-5D77015655CB}"); To("{CBFF58A2-7B50-4F75-8E98-249920DB0F37}"); // fixme cascade - //To("{3D18920C-E84D-405C-A06A-B7CEE52FE5DD}"); // we're going to drop them anyways To("{5CB66059-45F4-48BA-BCBD-C5035D79206B}"); To("{FB0A5429-587E-4BD0-8A67-20F0E7E62FF7}"); To("{F0C42457-6A3B-4912-A7EA-F27ED85A2092}"); @@ -117,21 +117,18 @@ namespace Umbraco.Core.Migrations.Upgrade To("{5F4597F4-A4E0-4AFE-90B5-6D2F896830EB}"); To("{290C18EE-B3DE-4769-84F1-1F467F3F76DA}"); To("{6A2C7C1B-A9DB-4EA9-B6AB-78E7D5B722A7}"); - //To("{77874C77-93E5-4488-A404-A630907CEEF0}"); // we're going to recreate keys at the end To("{8804D8E8-FE62-4E3A-B8A2-C047C2118C38}"); To("{23275462-446E-44C7-8C2C-3B8C1127B07D}"); To("{6B251841-3069-4AD5-8AE9-861F9523E8DA}"); To("{EE429F1B-9B26-43CA-89F8-A86017C809A3}"); To("{08919C4B-B431-449C-90EC-2B8445B5C6B1}"); To("{7EB0254C-CB8B-4C75-B15B-D48C55B449EB}"); - //To("{648A2D5F-7467-48F8-B309-E99CEEE00E2A}"); // duplicate (see above) To("{C39BF2A7-1454-4047-BBFE-89E40F66ED63}"); To("{64EBCE53-E1F0-463A-B40B-E98EFCCA8AE2}"); To("{0009109C-A0B8-4F3F-8FEB-C137BBDDA268}"); To("{ED28B66A-E248-4D94-8CDB-9BDF574023F0}"); To("{38C809D5-6C34-426B-9BEA-EFD39162595C}"); To("{6017F044-8E70-4E10-B2A3-336949692ADD}"); - To("{98339BEF-E4B2-48A8-B9D1-D173DC842BBE}"); Merge() .To("{CDBEDEE4-9496-4903-9CF2-4104E00FF960}") @@ -139,12 +136,22 @@ namespace Umbraco.Core.Migrations.Upgrade .To("{940FD19A-00A8-4D5C-B8FF-939143585726}") .As("{0576E786-5C30-4000-B969-302B61E90CA3}"); + To("{48AD6CCD-C7A4-4305-A8AB-38728AD23FC5}"); + + // finish migrating from v7 - recreate all keys and indexes To("{3F9764F5-73D0-4D45-8804-1240A66E43A2}"); To("{E0CBE54D-A84F-4A8F-9B13-900945FD7ED9}"); - To("{78BAF571-90D0-4D28-8175-EF96316DA789}"); // release-8.0.0 - To("{80C0A0CB-0DD5-4573-B000-C4B7C313C70D}"); // release-8.0.1 + To("{78BAF571-90D0-4D28-8175-EF96316DA789}"); + // release-8.0.0 + + // to 8.0.1... + To("{80C0A0CB-0DD5-4573-B000-C4B7C313C70D}"); + // release-8.0.1 + + // to 8.1.0... To("{B69B6E8C-A769-4044-A27E-4A4E18D1645A}"); + To("{0372A42B-DECF-498D-B4D1-6379E907EB94}"); //FINAL } diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddLockTable.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddLockTable.cs deleted file mode 100644 index 88c6e0bf98..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddLockTable.cs +++ /dev/null @@ -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(true); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddUserLoginDtoDateIndex.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddUserLoginDtoDateIndex.cs deleted file mode 100644 index 0ccc2d93ff..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/AddUserLoginDtoDateIndex.cs +++ /dev/null @@ -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(); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/FixLanguageIsoCodeLength.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/FixLanguageIsoCodeLength.cs new file mode 100644 index 0000000000..8de06c9a6f --- /dev/null +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/FixLanguageIsoCodeLength.cs @@ -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(); + } + } +} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/FixLockTablePrimaryKey.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/FixLockTablePrimaryKey.cs deleted file mode 100644 index fbb233927b..0000000000 --- a/src/Umbraco.Core/Migrations/Upgrade/V_8_0_0/FixLockTablePrimaryKey.cs +++ /dev/null @@ -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(); - } - } -} diff --git a/src/Umbraco.Core/Migrations/Upgrade/V_8_1_0/RenameUserLoginDtoDateIndex.cs b/src/Umbraco.Core/Migrations/Upgrade/V_8_1_0/RenameUserLoginDtoDateIndex.cs new file mode 100644 index 0000000000..c0b9c8f2db --- /dev/null +++ b/src/Umbraco.Core/Migrations/Upgrade/V_8_1_0/RenameUserLoginDtoDateIndex.cs @@ -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(); + } + } +} diff --git a/src/Umbraco.Core/Persistence/Dtos/UserLoginDto.cs b/src/Umbraco.Core/Persistence/Dtos/UserLoginDto.cs index d7d02631b7..8bf254ea31 100644 --- a/src/Umbraco.Core/Persistence/Dtos/UserLoginDto.cs +++ b/src/Umbraco.Core/Persistence/Dtos/UserLoginDto.cs @@ -37,7 +37,7 @@ namespace Umbraco.Core.Persistence.Dtos /// [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; } /// diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 7730608f36..24999f56c8 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -222,12 +222,14 @@ + + @@ -388,7 +390,6 @@ - @@ -401,7 +402,6 @@ - @@ -691,7 +691,6 @@ - From 33778882194fd9d1688c77d5f6ee18573ca484bc Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Fri, 10 May 2019 21:45:06 +0200 Subject: [PATCH 28/82] Prompt to save changes after pasting items into Nested Content --- .../propertyeditors/nestedcontent/nestedcontent.controller.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js index 7a67e07e0c..13295b1fbc 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js @@ -356,6 +356,7 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.NestedContent.Prop newNode.key = String.CreateGuid(); $scope.nodes.push(newNode); + $scope.setDirty(); //updateModel();// done by setting current node... $scope.currentNode = newNode; From 9b0d16f0addaf42dc2ea520885326fd62075be92 Mon Sep 17 00:00:00 2001 From: Matthew Wise <6782865+Matthew-Wise@users.noreply.github.com> Date: Sat, 11 May 2019 17:31:37 +0100 Subject: [PATCH 29/82] Added aria label for validation messages on login --- .../views/components/application/umb-login.html | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/components/application/umb-login.html b/src/Umbraco.Web.UI.Client/src/views/components/application/umb-login.html index baf9af916c..e7513617b7 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/application/umb-login.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/application/umb-login.html @@ -148,10 +148,9 @@
    -
    -
    {{vm.errorMsg}}
    +
    +
    -
    @@ -169,12 +168,11 @@
    - +
    Forgotten password? From cb76914a27adaa4a91080890b761ac81f1dd838e Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Tue, 14 May 2019 09:09:18 +0200 Subject: [PATCH 30/82] Don't load the breadcrumb twice when editing content --- .../components/content/edit.controller.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js index f7704ab870..3a874f83c6 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js @@ -67,16 +67,12 @@ //We fetch all ancestors of the node to generate the footer breadcrumb navigation if (!$scope.page.isNew) { if (content.parentId && content.parentId !== -1) { - entityResource.getAncestors(content.id, "document", $scope.culture) - .then(function (anc) { - $scope.ancestors = anc; - }); + loadBreadcrumb(); $scope.$watch('culture', function (value, oldValue) { - entityResource.getAncestors(content.id, "document", value) - .then(function (anc) { - $scope.ancestors = anc; - }); + if (value !== oldValue) { + loadBreadcrumb(); + } }); } } @@ -86,6 +82,12 @@ resetVariantFlags(); } + function loadBreadcrumb() { + entityResource.getAncestors($scope.content.id, "document", $scope.culture) + .then(function (anc) { + $scope.ancestors = anc; + }); + } /** * This will reset isDirty flags if save is true. From 61ba78538afad3b028a9ccc39c533e1e66d85015 Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Tue, 14 May 2019 12:20:58 +0100 Subject: [PATCH 31/82] Added hotkeys for schedule and publish with descendants --- .../src/common/services/contenteditinghelper.service.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js index 1efcf84dcb..1b2be5f635 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js @@ -197,6 +197,8 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, notifica letter: ch, labelKey: "buttons_schedulePublish", handler: args.methods.schedulePublish, + hotKey: "alt+shift+s", + hotKeyWhenHidden: true, alias: "schedulePublish", addEllipsis: "true" }; @@ -207,6 +209,8 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, notifica letter: ch, labelKey: "buttons_publishDescendants", handler: args.methods.publishDescendants, + hotKey: "alt+shift+p", + hotKeyWhenHidden: true, alias: "publishDescendant", addEllipsis: "true" }; From c0c9f4dfcc866770074c8895baaac09f53ab14c8 Mon Sep 17 00:00:00 2001 From: Ollie Philpott Date: Tue, 14 May 2019 12:21:29 +0100 Subject: [PATCH 32/82] Changed publish submenu rendering to allow working hotkeys --- .../src/views/components/buttons/umb-button-group.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/components/buttons/umb-button-group.html b/src/Umbraco.Web.UI.Client/src/views/components/buttons/umb-button-group.html index 054681d7f1..82f09de46c 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/buttons/umb-button-group.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/buttons/umb-button-group.html @@ -23,7 +23,7 @@ - + {{subButton.labelKey}} From d255cd115b494a3ea1e33cc92c1886b46ff82c7e Mon Sep 17 00:00:00 2001 From: Tiffany Prosser Date: Tue, 14 May 2019 13:45:49 +0100 Subject: [PATCH 33/82] fixed sections.less focus states on top menu --- src/Umbraco.Web.UI.Client/src/less/sections.less | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/less/sections.less b/src/Umbraco.Web.UI.Client/src/less/sections.less index 5a1de02617..eecfa57ee8 100644 --- a/src/Umbraco.Web.UI.Client/src/less/sections.less +++ b/src/Umbraco.Web.UI.Client/src/less/sections.less @@ -57,16 +57,17 @@ ul.sections>li.current>a::after { opacity: 1; transform: translateY(0px); } -ul.sections>li.current>a .section__name, -ul.sections>li>a:hover .section__name, -ul.sections>li>a:focus .section__name { - opacity: 1; +ul.sections > li.current > a .section__name, +ul.sections > li > a:hover .section__name { + opacity: 1; -webkit-font-smoothing: subpixel-antialiased; } -ul.sections>li>a:focus .section__name { +ul.sections > li > a:focus .section__name { .tabbing-active & { box-shadow: 0 0 2px @pinkLight, inset 0 0 2px 1px @pinkLight; + border: 1px solid; + border-color: @navbarLinkColorHover; } } From ef15c247c29f28ceb20dd1d19f1a0bcfd7ca7097 Mon Sep 17 00:00:00 2001 From: Tiffany Prosser Date: Tue, 14 May 2019 14:05:09 +0100 Subject: [PATCH 34/82] updated styles on focus state on section menu --- src/Umbraco.Web.UI.Client/src/less/sections.less | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/less/sections.less b/src/Umbraco.Web.UI.Client/src/less/sections.less index eecfa57ee8..ef6c5f5046 100644 --- a/src/Umbraco.Web.UI.Client/src/less/sections.less +++ b/src/Umbraco.Web.UI.Client/src/less/sections.less @@ -65,9 +65,9 @@ ul.sections > li > a:hover .section__name { ul.sections > li > a:focus .section__name { .tabbing-active & { - box-shadow: 0 0 2px @pinkLight, inset 0 0 2px 1px @pinkLight; + border: 1px solid; - border-color: @navbarLinkColorHover; + border-color: @gray-9; } } From 12d79f2d089848b74f025dedb17e35987f681937 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Tue, 14 May 2019 17:54:37 +0200 Subject: [PATCH 35/82] Use umb-load-indicator when loading the RTE --- src/Umbraco.Web.UI.Client/src/less/rte.less | 4 ---- .../src/views/propertyeditors/rte/rte.html | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/less/rte.less b/src/Umbraco.Web.UI.Client/src/less/rte.less index ccf52acc53..a13dbaeb43 100644 --- a/src/Umbraco.Web.UI.Client/src/less/rte.less +++ b/src/Umbraco.Web.UI.Client/src/less/rte.less @@ -5,10 +5,6 @@ position: relative; .umb-property-editor--limit-width(); - - .-loading { - position: absolute; - } } .umb-rte .mce-tinymce { diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/rte/rte.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/rte/rte.html index 57e837c497..a68bfe978e 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/rte/rte.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/rte/rte.html @@ -1,5 +1,5 @@
    -
    Loading...
    +
    From 9706a0f76ad9f1640bd63466dc5750dd9b4b14dc Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Wed, 15 May 2019 08:32:47 +0200 Subject: [PATCH 36/82] Remove sort order and add item icons in content and media sort dialogs --- src/Umbraco.Web.UI.Client/src/less/hacks.less | 9 +++++++++ .../src/views/content/sort.html | 16 +++------------- .../src/views/media/sort.html | 15 +++------------ 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/less/hacks.less b/src/Umbraco.Web.UI.Client/src/less/hacks.less index 726b3fa5ed..0b6d1b7a60 100644 --- a/src/Umbraco.Web.UI.Client/src/less/hacks.less +++ b/src/Umbraco.Web.UI.Client/src/less/hacks.less @@ -221,3 +221,12 @@ pre { border: 0; } } + +/* Styling for content/media sort order dialog */ +.sort-order { + td.tree-icon { + font-size:20px; + width:20px; + padding-right:0; + } +} diff --git a/src/Umbraco.Web.UI.Client/src/views/content/sort.html b/src/Umbraco.Web.UI.Client/src/views/content/sort.html index 789f7fe6b5..471f3de956 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/sort.html +++ b/src/Umbraco.Web.UI.Client/src/views/content/sort.html @@ -1,6 +1,6 @@
    -
  • + Timestamp   LevelMachineLevelMachine Message
    {{ log.Timestamp | date:'medium' }} {{ log.Level }} {{ log.Properties.MachineName.Value }}{{ log.RenderedMessage }}{{ log.RenderedMessage }}
    - - + -
    + @@ -37,22 +37,13 @@ - - - - - - - -
    {{ child.name }} {{ child.createDate }}{{ child.sortOrder }}
    @@ -86,4 +77,3 @@ - \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/media/sort.html b/src/Umbraco.Web.UI.Client/src/views/media/sort.html index 92632a3256..b893517f1c 100644 --- a/src/Umbraco.Web.UI.Client/src/views/media/sort.html +++ b/src/Umbraco.Web.UI.Client/src/views/media/sort.html @@ -1,6 +1,6 @@
    -