Browse Source

fix inefficient database migration (#2411)

pull/2412/head
Jason Dove 4 months ago committed by GitHub
parent
commit
c5265943f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 29
      ErsatzTV.Infrastructure.MySql/Migrations/20250825155751_Populate_PlayoutHistory_Finish.cs
  3. 31
      ErsatzTV.Infrastructure.Sqlite/Migrations/20250825155536_Populate_PlayoutHistory_Finish.cs
  4. 2
      ErsatzTV/appsettings.json

1
CHANGELOG.md

@ -47,6 +47,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -47,6 +47,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix watermarks and graphics elements when `Scaling Behavior` is `Crop`
- Fix hardware acceleration health check message on mobile
- Fix deco selection logic
- Fix inefficient database migration that would cause database initialization to get stuck
### Changed
- **BREAKING CHANGE**: change how `Scripted Schedule` system works

29
ErsatzTV.Infrastructure.MySql/Migrations/20250825155751_Populate_PlayoutHistory_Finish.cs

@ -10,17 +10,28 @@ namespace ErsatzTV.Infrastructure.MySql.Migrations @@ -10,17 +10,28 @@ namespace ErsatzTV.Infrastructure.MySql.Migrations
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_PlayoutItem_PlayoutId_Start",
table: "PlayoutItem",
columns: new[] { "PlayoutId", "Start" });
migrationBuilder.CreateIndex(
name: "IX_PlayoutHistory_PlayoutId_When",
table: "PlayoutHistory",
columns: new[] { "PlayoutId", "When" });
migrationBuilder.Sql(
@"UPDATE PlayoutHistory
SET Finish =
(SELECT PlayoutItem.Finish
FROM PlayoutItem
WHERE PlayoutItem.PlayoutId = PlayoutHistory.PlayoutId
AND PlayoutItem.Start = PlayoutHistory.`When`)
WHERE EXISTS (SELECT 1
FROM PlayoutItem
WHERE PlayoutItem.PlayoutId = PlayoutHistory.PlayoutId
AND PlayoutItem.Start = PlayoutHistory.`When`);");
JOIN PlayoutItem ON PlayoutHistory.PlayoutId = PlayoutItem.PlayoutId AND PlayoutHistory.`When` = PlayoutItem.Start
SET PlayoutHistory.Finish = PlayoutItem.Finish");
migrationBuilder.DropIndex(
name: "IX_PlayoutItem_PlayoutId_Start",
table: "PlayoutItem");
migrationBuilder.DropIndex(
name: "IX_PlayoutHistory_PlayoutId_When",
table: "PlayoutHistory");
}
/// <inheritdoc />

31
ErsatzTV.Infrastructure.Sqlite/Migrations/20250825155536_Populate_PlayoutHistory_Finish.cs

@ -10,17 +10,30 @@ namespace ErsatzTV.Infrastructure.Sqlite.Migrations @@ -10,17 +10,30 @@ namespace ErsatzTV.Infrastructure.Sqlite.Migrations
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_PlayoutItem_PlayoutId_Start",
table: "PlayoutItem",
columns: new[] { "PlayoutId", "Start" });
migrationBuilder.CreateIndex(
name: "IX_PlayoutHistory_PlayoutId_When",
table: "PlayoutHistory",
columns: new[] { "PlayoutId", "When" });
migrationBuilder.Sql(
@"UPDATE PlayoutHistory
SET Finish =
(SELECT PlayoutItem.Finish
FROM PlayoutItem
WHERE PlayoutItem.PlayoutId = PlayoutHistory.PlayoutId
AND PlayoutItem.Start = PlayoutHistory.`When`)
WHERE EXISTS (SELECT 1
FROM PlayoutItem
WHERE PlayoutItem.PlayoutId = PlayoutHistory.PlayoutId
AND PlayoutItem.Start = PlayoutHistory.`When`);");
SET Finish = PlayoutItem.Finish
FROM PlayoutItem
WHERE PlayoutHistory.PlayoutId = PlayoutItem.PlayoutId
AND PlayoutHistory.`When` = PlayoutItem.Start;");
migrationBuilder.DropIndex(
name: "IX_PlayoutItem_PlayoutId_Start",
table: "PlayoutItem");
migrationBuilder.DropIndex(
name: "IX_PlayoutHistory_PlayoutId_When",
table: "PlayoutHistory");
}
/// <inheritdoc />

2
ErsatzTV/appsettings.json

@ -23,4 +23,4 @@ @@ -23,4 +23,4 @@
"ApiKey": "f59f3cc93cce91210a5c0f047eb2047c",
"Enable": true
}
}
}

Loading…
Cancel
Save