diff --git a/ErsatzTV.Infrastructure.MySql/Migrations/20251213202531_Fix_DuplicateSmartCollectionName.cs b/ErsatzTV.Infrastructure.MySql/Migrations/20251213202531_Fix_DuplicateSmartCollectionName.cs index 5becdf239..74dfc7c23 100644 --- a/ErsatzTV.Infrastructure.MySql/Migrations/20251213202531_Fix_DuplicateSmartCollectionName.cs +++ b/ErsatzTV.Infrastructure.MySql/Migrations/20251213202531_Fix_DuplicateSmartCollectionName.cs @@ -12,16 +12,15 @@ namespace ErsatzTV.Infrastructure.MySql.Migrations { migrationBuilder.Sql( @" - WITH Numbered AS ( +UPDATE SmartCollection sc + JOIN ( SELECT Id, ROW_NUMBER() OVER (PARTITION BY Name ORDER BY Id) as RowNum FROM SmartCollection - ) - UPDATE SmartCollection sc - JOIN Numbered n ON sc.Id = n.Id - SET sc.Name = CONCAT(sc.Name, ' (', n.RowNum - 1, ')') - WHERE n.RowNum > 1; + ) n ON sc.Id = n.Id +SET sc.Name = CONCAT(sc.Name, ' (', n.RowNum - 1, ')') +WHERE n.RowNum > 1; "); } diff --git a/ErsatzTV.Infrastructure.MySql/Migrations/20251214002940_Fix_SmartCollectionNameSensitivity.cs b/ErsatzTV.Infrastructure.MySql/Migrations/20251214002940_Fix_SmartCollectionNameSensitivity.cs index b2ce3048d..3b61ee41c 100644 --- a/ErsatzTV.Infrastructure.MySql/Migrations/20251214002940_Fix_SmartCollectionNameSensitivity.cs +++ b/ErsatzTV.Infrastructure.MySql/Migrations/20251214002940_Fix_SmartCollectionNameSensitivity.cs @@ -12,16 +12,15 @@ namespace ErsatzTV.Infrastructure.MySql.Migrations { migrationBuilder.Sql( @" - WITH Numbered AS ( +UPDATE SmartCollection sc + JOIN ( SELECT Id, ROW_NUMBER() OVER (PARTITION BY LOWER(Name) ORDER BY Id) as RowNum FROM SmartCollection - ) - UPDATE SmartCollection sc - JOIN Numbered n ON sc.Id = n.Id - SET sc.Name = CONCAT(sc.Name, ' (', n.RowNum - 1, ')') - WHERE n.RowNum > 1; + ) n ON sc.Id = n.Id +SET sc.Name = CONCAT(sc.Name, ' (', n.RowNum - 1, ')') +WHERE n.RowNum > 1; "); migrationBuilder.AlterColumn(