Browse Source

fix some mysql migrations that failed on mariadb (#2725)

pull/2726/head
Jason Dove 2 weeks ago committed by GitHub
parent
commit
e4f1a93db0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  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