using Backend.Data;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Backend.Migrations;

[DbContext(typeof(AwardsDbContext))]
[Migration("20260629210000_EnsureRuntimeSchemaParity")]
public partial class EnsureRuntimeSchemaParity : Migration
{
    protected override void Up(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.Sql(
            """
            ALTER TABLE "SiteSettings" ADD COLUMN IF NOT EXISTS "HostImageData" bytea;
            ALTER TABLE "SiteSettings" ADD COLUMN IF NOT EXISTS "HostImageContentType" character varying(80);
            ALTER TABLE "SiteSettings" ADD COLUMN IF NOT EXISTS "HostImageUpdatedAt" timestamp with time zone;
            ALTER TABLE "SiteSettings" ADD COLUMN IF NOT EXISTS "HostArtistName" character varying(120) NOT NULL DEFAULT '';
            ALTER TABLE "Nominations" ADD COLUMN IF NOT EXISTS "StreamUrl" character varying(300);
            """
        );
    }

    protected override void Down(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.Sql(
            """
            ALTER TABLE "Nominations" DROP COLUMN IF EXISTS "StreamUrl";
            ALTER TABLE "SiteSettings" DROP COLUMN IF EXISTS "HostArtistName";
            ALTER TABLE "SiteSettings" DROP COLUMN IF EXISTS "HostImageUpdatedAt";
            ALTER TABLE "SiteSettings" DROP COLUMN IF EXISTS "HostImageContentType";
            ALTER TABLE "SiteSettings" DROP COLUMN IF EXISTS "HostImageData";
            """
        );
    }
}
