Files
ersatztv/ErsatzTV.Infrastructure.Sqlite/Migrations/20211024113804_Fix_ProgramScheduleItemMidnightStartTime.cs
T
Jason DoveandGitHub a7661c8498 add mysql database provider (#1375)
* refactor sqlite into separate library

* support mysql

* fixes

* sql fixes

* cleanup

* update changelog
2023-08-12 21:44:14 -05:00

39 lines
1.4 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
namespace ErsatzTV.Infrastructure.Sqlite.Migrations
{
public partial class Fix_ProgramScheduleItemMidnightStartTime : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(
"update ProgramScheduleItem set StartTime = '00:00:00' where StartTime = '1.00:00:00'");
migrationBuilder.Sql(
@"delete from PlayoutItem where PlayoutId in
(select Playout.Id from Playout
inner join ProgramSchedule PS on Playout.ProgramScheduleId = PS.Id
inner join ProgramScheduleItem PSI on PSI.ProgramScheduleId = PS.Id
where PSI.StartTime = '00:00:00')");
migrationBuilder.Sql(
@"delete from PlayoutProgramScheduleAnchor where PlayoutId in
(select Playout.Id from Playout
inner join ProgramSchedule PS on Playout.ProgramScheduleId = PS.Id
inner join ProgramScheduleItem PSI on PSI.ProgramScheduleId = PS.Id
where PSI.StartTime = '00:00:00')");
migrationBuilder.Sql(
@"UPDATE Playout SET Anchor_NextStart = null, Anchor_NextScheduleItemId = null where Id in
(select Playout.Id from Playout
inner join ProgramSchedule PS on Playout.ProgramScheduleId = PS.Id
inner join ProgramScheduleItem PSI on PSI.ProgramScheduleId = PS.Id
where PSI.StartTime = '00:00:00')");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}