diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs index 141200f5f5..2844d53d80 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs @@ -1,5 +1,6 @@ using Umbraco.Cms.Core; using Umbraco.Cms.Core.Configuration; +using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_10_7_0; namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade; @@ -68,12 +69,21 @@ public class UmbracoPlan : MigrationPlan // To 10.5.0 / 11.2.0 To("{83AF7945-DADE-4A02-9041-F3F6EBFAC319}"); + // to 10.7.0 + To("{EF93F398-1385-4F07-808A-D3C518984442}"); + // To 11.3.0 To("{BB3889ED-E2DE-49F2-8F71-5FD8616A2661}"); // To 11.4.0 To("{FFB6B9B0-F1A8-45E9-9CD7-25700577D1CA}"); + // to 11.4.3 + // This is here twice since it was added in 10, so if you had already upgraded you wouldn't get it + // But we still need the first once, since if you upgraded to 10.7.0 then the "From" state would be unknown otherwise. + // This has it's own key, we essentially consider it a separate migration. + To("{2CA0C5BB-170B-45E5-8179-E73DA4B41A46}"); + // To 12.0.0 To("{888A0D5D-51E4-4C7E-AA0A-01306523C7FB}"); To("{539F2F83-FBA7-4C48-81A3-75081A56BB9D}"); @@ -81,5 +91,8 @@ public class UmbracoPlan : MigrationPlan // To 12.1.0 To("{1187192D-EDB5-4619-955D-91D48D738871}"); To("{47DE85CE-1E16-42A0-8AF6-3EC3BCEF5471}"); + + // And once more for 12 + To("{2D4C9FBD-08B3-472D-A76C-6ED467A0CD20}"); } } diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_10_7_0/MigrateTagsFromNVarcharToNText.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_10_7_0/MigrateTagsFromNVarcharToNText.cs new file mode 100644 index 0000000000..462e3772fa --- /dev/null +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_10_7_0/MigrateTagsFromNVarcharToNText.cs @@ -0,0 +1,46 @@ +using NPoco; +using Umbraco.Cms.Core; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Infrastructure.Persistence; +using Umbraco.Cms.Infrastructure.Persistence.Dtos; +using Umbraco.Extensions; + +namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_10_7_0; + +public class MigrateTagsFromNVarcharToNText : MigrationBase +{ + public MigrateTagsFromNVarcharToNText(IMigrationContext context) + : base(context) + { + } + + protected override void Migrate() + { + // Firstly change the storage type for the Umbraco.Tags property editor + Sql updateDbTypeForTagsQuery = Database.SqlContext.Sql() + .Update(x => x.Set(dt => dt.DbType, ValueStorageType.Ntext.ToString())) + .Where(dt => dt.EditorAlias == Constants.PropertyEditors.Aliases.Tags); + + Database.Execute(updateDbTypeForTagsQuery); + + // Then migrate the data from "varcharValue" column to "textValue" + Sql tagsDataTypeIdQuery = Database.SqlContext.Sql() + .Select(dt => dt.NodeId) + .From() + .Where(dt => dt.EditorAlias == Constants.PropertyEditors.Aliases.Tags); + + Sql tagsPropertyTypeIdQuery = Database.SqlContext.Sql() + .Select(pt => pt.Id) + .From() + .WhereIn(pt => pt.DataTypeId, tagsDataTypeIdQuery); + + Sql updatePropertyDataColumnsQuery = Database.SqlContext.Sql() + .Update() + .Append("SET textValue = varcharValue, varcharValue = null") + .WhereIn(pd => pd.PropertyTypeId, tagsPropertyTypeIdQuery) + .Where(pd => pd.TextValue == null) + .Where(pd => pd.VarcharValue != null); + + Database.Execute(updatePropertyDataColumnsQuery); + } +} diff --git a/src/Umbraco.Infrastructure/PropertyEditors/TagsPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/TagsPropertyEditor.cs index 1923950fe0..0120d6a2a1 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/TagsPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/TagsPropertyEditor.cs @@ -25,7 +25,8 @@ namespace Umbraco.Cms.Core.PropertyEditors; "Tags", "tags", Icon = "icon-tags", - ValueEditorIsReusable = true)] + ValueEditorIsReusable = true, + ValueType = ValueTypes.Text)] public class TagsPropertyEditor : DataEditor { private readonly IEditorConfigurationParser _editorConfigurationParser; diff --git a/src/Umbraco.Infrastructure/Runtime/RuntimeState.cs b/src/Umbraco.Infrastructure/Runtime/RuntimeState.cs index 37c99c64f2..53eecfc8d3 100644 --- a/src/Umbraco.Infrastructure/Runtime/RuntimeState.cs +++ b/src/Umbraco.Infrastructure/Runtime/RuntimeState.cs @@ -218,7 +218,7 @@ public class RuntimeState : IRuntimeState if (_globalSettings.Value.InstallMissingDatabase || _databaseProviderMetadata.CanForceCreateDatabase(_databaseFactory)) { // ok to install on a configured but missing database - Level = RuntimeLevel.Install; + Level = RuntimeLevel.BootFailed; Reason = RuntimeLevelReason.InstallMissingDatabase; return; } diff --git a/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs b/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs index 5708b3c4fd..1125d542da 100644 --- a/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs +++ b/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs @@ -1,5 +1,6 @@ using System.Reflection; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; using Umbraco.Cms.Core; @@ -25,8 +26,6 @@ namespace Umbraco.Cms.Web.BackOffice.Install; [Area(Constants.Web.Mvc.InstallArea)] public class InstallApiController : ControllerBase { - private readonly IBackOfficeSignInManager _backOfficeSignInManager; - private readonly IBackOfficeUserManager _backOfficeUserManager; private readonly DatabaseBuilder _databaseBuilder; private readonly InstallStatusTracker _installStatusTracker; private readonly InstallStepCollection _installSteps; @@ -34,6 +33,7 @@ public class InstallApiController : ControllerBase private readonly IProfilingLogger _proflog; private readonly IRuntime _runtime; + [Obsolete("Use the constructor without IBackOfficeUserManager & IBackOfficeSignInManager instead, scheduled for removal in v14")] public InstallApiController( DatabaseBuilder databaseBuilder, IProfilingLogger proflog, @@ -44,14 +44,25 @@ public class InstallApiController : ControllerBase IRuntime runtime, IBackOfficeUserManager backOfficeUserManager, IBackOfficeSignInManager backOfficeSignInManager) + : this(databaseBuilder, proflog, logger, installHelper, installSteps, installStatusTracker, runtime) + { + } + + [ActivatorUtilitiesConstructor] + public InstallApiController( + DatabaseBuilder databaseBuilder, + IProfilingLogger proflog, + ILogger logger, + InstallHelper installHelper, + InstallStepCollection installSteps, + InstallStatusTracker installStatusTracker, + IRuntime runtime) { _databaseBuilder = databaseBuilder ?? throw new ArgumentNullException(nameof(databaseBuilder)); _proflog = proflog ?? throw new ArgumentNullException(nameof(proflog)); _installSteps = installSteps; _installStatusTracker = installStatusTracker; _runtime = runtime; - _backOfficeUserManager = backOfficeUserManager; - _backOfficeSignInManager = backOfficeSignInManager; InstallHelper = installHelper; _logger = logger; } @@ -88,20 +99,8 @@ public class InstallApiController : ControllerBase [HttpPost] public async Task CompleteInstall() { - RuntimeLevel levelBeforeRestart = _runtime.State.Level; - await _runtime.RestartAsync(); - if (levelBeforeRestart == RuntimeLevel.Install) - { - BackOfficeIdentityUser? identityUser = - await _backOfficeUserManager.FindByIdAsync(Core.Constants.Security.SuperUserIdAsString); - if (identityUser is not null) - { - _backOfficeSignInManager.SignInAsync(identityUser, false); - } - } - return NoContent(); }