Merge remote-tracking branch 'origin/v10/dev' into v11/dev

# Conflicts:
#	src/JsonSchema/AppSettings.cs
#	src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs
This commit is contained in:
nikolajlauridsen
2023-07-14 09:33:57 +02:00
3 changed files with 56 additions and 1 deletions

View File

@@ -65,10 +65,18 @@ public class UmbracoPlan : MigrationPlan
// To 10.5.0 / 11.2.0
To<V_10_5_0.AddPrimaryKeyConstrainToContentVersionCleanupDtos>("{83AF7945-DADE-4A02-9041-F3F6EBFAC319}");
// to 10.7.0
To<MigrateTagsFromNVarcharToNText>("{EF93F398-1385-4F07-808A-D3C518984442}");
// To 11.3.0
To<V_11_3_0.AddDomainSortOrder>("{BB3889ED-E2DE-49F2-8F71-5FD8616A2661}");
// To 11.4.0
To<V_11_4_0.AlterKeyValueDataType>("{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.
To<MigrateTagsFromNVarcharToNText>("{EF93F398-1385-4F07-808A-D3C518984442}");
}
}

View File

@@ -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<ISqlContext> updateDbTypeForTagsQuery = Database.SqlContext.Sql()
.Update<DataTypeDto>(x => x.Set(dt => dt.DbType, ValueStorageType.Ntext.ToString()))
.Where<DataTypeDto>(dt => dt.EditorAlias == Constants.PropertyEditors.Aliases.Tags);
Database.Execute(updateDbTypeForTagsQuery);
// Then migrate the data from "varcharValue" column to "textValue"
Sql<ISqlContext> tagsDataTypeIdQuery = Database.SqlContext.Sql()
.Select<DataTypeDto>(dt => dt.NodeId)
.From<DataTypeDto>()
.Where<DataTypeDto>(dt => dt.EditorAlias == Constants.PropertyEditors.Aliases.Tags);
Sql<ISqlContext> tagsPropertyTypeIdQuery = Database.SqlContext.Sql()
.Select<PropertyTypeDto>(pt => pt.Id)
.From<PropertyTypeDto>()
.WhereIn<PropertyTypeDto>(pt => pt.DataTypeId, tagsDataTypeIdQuery);
Sql<ISqlContext> updatePropertyDataColumnsQuery = Database.SqlContext.Sql()
.Update<PropertyDataDto>()
.Append("SET textValue = varcharValue, varcharValue = null")
.WhereIn<PropertyDataDto>(pd => pd.PropertyTypeId, tagsPropertyTypeIdQuery)
.Where<PropertyDataDto>(pd => pd.TextValue == null)
.Where<PropertyDataDto>(pd => pd.VarcharValue != null);
Database.Execute(updatePropertyDataColumnsQuery);
}
}

View File

@@ -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;