using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Backend.Migrations;

[DbContext(typeof(Data.AwardsDbContext))]
[Migration("20260629194000_RemoveDemoSeasons")]
public partial class RemoveDemoSeasons : Migration
{
    protected override void Up(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.Sql(
            """
            UPDATE "RiskFlags"
            SET "SeasonId" = NULL
            WHERE "SeasonId" IN (
                SELECT "Id"
                FROM "Seasons"
                WHERE "IsDemo" = TRUE
            );

            DELETE FROM "Seasons"
            WHERE "IsDemo" = TRUE;
            """
        );
    }

    protected override void Down(MigrationBuilder migrationBuilder)
    {
    }
}
