diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_17_4_0/FixLabelDataTypeDbTypeFromConfiguration.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_17_4_0/FixLabelDataTypeDbTypeFromConfiguration.cs
index 1c9f8b9c5060..18e59a58307d 100644
--- a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_17_4_0/FixLabelDataTypeDbTypeFromConfiguration.cs
+++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_17_4_0/FixLabelDataTypeDbTypeFromConfiguration.cs
@@ -3,6 +3,8 @@
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Persistence;
+using Umbraco.Cms.Infrastructure.Persistence.Dtos;
+using Umbraco.Cms.Infrastructure.Persistence.SqlSyntax;
namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_17_4_0;
@@ -67,20 +69,21 @@ internal static async Task ExecuteMigration(IUmbracoDatabase database, IDataType
// could exceed the default command timeout, so extend it here.
EnsureLongCommandTimeout(database);
+ ISqlSyntaxProvider syntax = database.SqlContext.SqlSyntax;
var sql = $@"
-UPDATE umbracoPropertyData
-SET textValue = varcharValue, varcharValue = NULL
-WHERE propertyTypeId IN (
- SELECT id
- FROM cmsPropertyType
- WHERE dataTypeId IN (
- SELECT nodeId
- FROM umbracoDataType
- WHERE propertyEditorAlias = '{Constants.PropertyEditors.Aliases.Label}'
- AND dbType = '{nameof(ValueStorageType.Ntext)}'
+UPDATE {syntax.GetQuotedTableName(PropertyDataDto.TableName)}
+SET {syntax.GetQuotedColumnName(PropertyDataDto.TextValueColumnName)} = {syntax.GetQuotedColumnName(PropertyDataDto.VarcharValueColumnName)}, {syntax.GetQuotedColumnName(PropertyDataDto.VarcharValueColumnName)} = NULL
+WHERE {syntax.GetQuotedColumnName(PropertyDataDto.PropertyTypeIdColumnName)} IN (
+ SELECT {syntax.GetQuotedColumnName(PropertyTypeDto.PrimaryKeyColumnName)}
+ FROM {syntax.GetQuotedTableName(PropertyTypeDto.TableName)}
+ WHERE {syntax.GetQuotedColumnName(PropertyTypeDto.DataTypeIdColumnName)} IN (
+ SELECT {syntax.GetQuotedColumnName(DataTypeDto.PrimaryKeyColumnName)}
+ FROM {syntax.GetQuotedTableName(DataTypeDto.TableName)}
+ WHERE {syntax.GetQuotedColumnName(DataTypeDto.EditorAliasColumnName)} = '{Constants.PropertyEditors.Aliases.Label}'
+ AND {syntax.GetQuotedColumnName(DataTypeDto.DbTypeColumnName)} = '{nameof(ValueStorageType.Ntext)}'
)
)
-AND varcharValue IS NOT NULL";
+AND {syntax.GetQuotedColumnName(PropertyDataDto.VarcharValueColumnName)} IS NOT NULL";
await database.ExecuteAsync(sql);
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/DataTypeDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/DataTypeDto.cs
index 8b22a66c1108..96ca46795237 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/DataTypeDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/DataTypeDto.cs
@@ -14,6 +14,8 @@ public class DataTypeDto
{
public const string TableName = Constants.DatabaseSchema.Tables.DataType;
public const string PrimaryKeyColumnName = Constants.DatabaseSchema.Columns.NodeIdName;
+ public const string EditorAliasColumnName = "propertyEditorAlias";
+ public const string DbTypeColumnName = "dbType";
///
/// Gets or sets the identifier of the associated node.
@@ -28,7 +30,7 @@ public class DataTypeDto
/// Gets or sets the alias of the property editor associated with this data type.
///
/// TODO: should this have a length
- [Column("propertyEditorAlias")]
+ [Column(EditorAliasColumnName)]
public string EditorAlias { get; set; } = null!;
///
@@ -41,7 +43,7 @@ public class DataTypeDto
///
/// Gets or sets the type of the database column used to store values for this data type.
///
- [Column("dbType")]
+ [Column(DbTypeColumnName)]
[Length(50)]
public string DbType { get; set; } = null!;
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/PropertyDataDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/PropertyDataDto.cs
index 229eef7d268d..03092c456c7c 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/PropertyDataDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/PropertyDataDto.cs
@@ -14,6 +14,8 @@ internal sealed class PropertyDataDto
public const string PrimaryKeyColumnName = Constants.DatabaseSchema.Columns.PrimaryKeyNameId;
public const string PropertyTypeIdColumnName = "propertyTypeId";
public const string VersionIdColumnName = "versionId";
+ public const string TextValueColumnName = "textValue";
+ public const string VarcharValueColumnName = "varcharValue";
public const int VarcharLength = 512;
public const int SegmentLength = 256;
@@ -93,7 +95,7 @@ public decimal? DecimalValue
/// Gets or sets the string value stored in the varcharValue column for this property data record.
/// This typically contains the value of a property when stored as a variable-length string.
///
- [Column("varcharValue")]
+ [Column(VarcharValueColumnName)]
[NullSetting(NullSetting = NullSettings.Null)]
[Length(VarcharLength)]
public string? VarcharValue { get; set; }
@@ -101,7 +103,7 @@ public decimal? DecimalValue
///
/// Gets or sets the text value associated with the property data in the database.
///
- [Column("textValue")]
+ [Column(TextValueColumnName)]
[NullSetting(NullSetting = NullSettings.Null)]
[SpecialDbType(SpecialDbTypes.NVARCHARMAX)]
public string? TextValue { get; set; }