Browse Source

use explicit ci collation for mysql

pull/2721/head
Jason Dove 8 months ago
parent
commit
4030b11fa3
No known key found for this signature in database
  1. 6886
      ErsatzTV.Infrastructure.MySql/Migrations/20251214002940_Fix_SmartCollectionNameSensitivity.Designer.cs
  2. 56
      ErsatzTV.Infrastructure.MySql/Migrations/20251214002940_Fix_SmartCollectionNameSensitivity.cs
  3. 3
      ErsatzTV.Infrastructure.MySql/Migrations/TvContextModelSnapshot.cs
  4. 2
      ErsatzTV.Infrastructure/Data/TvContext.cs

6886
ErsatzTV.Infrastructure.MySql/Migrations/20251214002940_Fix_SmartCollectionNameSensitivity.Designer.cs generated

File diff suppressed because it is too large Load Diff

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

@ -0,0 +1,56 @@ @@ -0,0 +1,56 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ErsatzTV.Infrastructure.MySql.Migrations
{
/// <inheritdoc />
public partial class Fix_SmartCollectionNameSensitivity : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(
@"
WITH Numbered AS (
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;
");
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "SmartCollection",
type: "varchar(255)",
nullable: true,
collation: "utf8mb4_general_ci",
oldClrType: typeof(string),
oldType: "varchar(255)",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "SmartCollection",
type: "varchar(255)",
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(255)",
oldNullable: true,
oldCollation: "utf8mb4_general_ci")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
}
}

3
ErsatzTV.Infrastructure.MySql/Migrations/TvContextModelSnapshot.cs

@ -3235,7 +3235,8 @@ namespace ErsatzTV.Infrastructure.MySql.Migrations @@ -3235,7 +3235,8 @@ namespace ErsatzTV.Infrastructure.MySql.Migrations
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.HasColumnType("varchar(255)");
.HasColumnType("varchar(255)")
.UseCollation("utf8mb4_general_ci");
b.Property<string>("Query")
.HasColumnType("longtext");

2
ErsatzTV.Infrastructure/Data/TvContext.cs

@ -130,6 +130,8 @@ public class TvContext : DbContext @@ -130,6 +130,8 @@ public class TvContext : DbContext
if ((Database.ProviderName ?? string.Empty).Contains("MySql", StringComparison.InvariantCultureIgnoreCase))
{
modelBuilder.Entity<MediaFile>().Property(mf => mf.Path).HasColumnType("longtext");
modelBuilder.Entity<SmartCollection>().Property(mc => mc.Name).UseCollation("utf8mb4_general_ci");
}
// sqlite-specific configuration

Loading…
Cancel
Save