Browse Source

fix some mysql migrations that failed on mariadb

pull/2725/head
Jason Dove 8 months ago
parent
commit
a38c700eae
No known key found for this signature in database
  1. 11
      ErsatzTV.Infrastructure.MySql/Migrations/20251213202531_Fix_DuplicateSmartCollectionName.cs
  2. 11
      ErsatzTV.Infrastructure.MySql/Migrations/20251214002940_Fix_SmartCollectionNameSensitivity.cs

11
ErsatzTV.Infrastructure.MySql/Migrations/20251213202531_Fix_DuplicateSmartCollectionName.cs

@ -12,16 +12,15 @@ namespace ErsatzTV.Infrastructure.MySql.Migrations
{ {
migrationBuilder.Sql( migrationBuilder.Sql(
@" @"
WITH Numbered AS ( UPDATE SmartCollection sc
JOIN (
SELECT SELECT
Id, Id,
ROW_NUMBER() OVER (PARTITION BY Name ORDER BY Id) as RowNum ROW_NUMBER() OVER (PARTITION BY Name ORDER BY Id) as RowNum
FROM SmartCollection FROM SmartCollection
) ) n ON sc.Id = n.Id
UPDATE SmartCollection sc SET sc.Name = CONCAT(sc.Name, ' (', n.RowNum - 1, ')')
JOIN Numbered n ON sc.Id = n.Id WHERE n.RowNum > 1;
SET sc.Name = CONCAT(sc.Name, ' (', n.RowNum - 1, ')')
WHERE n.RowNum > 1;
"); ");
} }

11
ErsatzTV.Infrastructure.MySql/Migrations/20251214002940_Fix_SmartCollectionNameSensitivity.cs

@ -12,16 +12,15 @@ namespace ErsatzTV.Infrastructure.MySql.Migrations
{ {
migrationBuilder.Sql( migrationBuilder.Sql(
@" @"
WITH Numbered AS ( UPDATE SmartCollection sc
JOIN (
SELECT SELECT
Id, Id,
ROW_NUMBER() OVER (PARTITION BY LOWER(Name) ORDER BY Id) as RowNum ROW_NUMBER() OVER (PARTITION BY LOWER(Name) ORDER BY Id) as RowNum
FROM SmartCollection FROM SmartCollection
) ) n ON sc.Id = n.Id
UPDATE SmartCollection sc SET sc.Name = CONCAT(sc.Name, ' (', n.RowNum - 1, ')')
JOIN Numbered n ON sc.Id = n.Id WHERE n.RowNum > 1;
SET sc.Name = CONCAT(sc.Name, ' (', n.RowNum - 1, ')')
WHERE n.RowNum > 1;
"); ");
migrationBuilder.AlterColumn<string>( migrationBuilder.AlterColumn<string>(

Loading…
Cancel
Save