using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Backend.Migrations
{
    /// <inheritdoc />
    public partial class AddOptionalClipFeatureSettings : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.Sql("""
                ALTER TABLE "SiteSettings"
                ADD COLUMN IF NOT EXISTS "ClipReviewEnabled" boolean NOT NULL DEFAULT true;
                """);

            migrationBuilder.Sql("""
                ALTER TABLE "SiteSettings"
                ADD COLUMN IF NOT EXISTS "ClipSubmissionDisabledMessage" character varying(240) NOT NULL DEFAULT 'Clip-Einreichungen sind aktuell geschlossen.';
                """);

            migrationBuilder.Sql("""
                ALTER TABLE "SiteSettings"
                ADD COLUMN IF NOT EXISTS "ClipSubmissionsEnabled" boolean NOT NULL DEFAULT false;
                """);

            migrationBuilder.UpdateData(
                table: "SiteSettings",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "ClipReviewEnabled", "ClipSubmissionDisabledMessage" },
                values: new object[] { true, "Clip-Einreichungen sind aktuell geschlossen." });
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.Sql("""
                ALTER TABLE "SiteSettings"
                DROP COLUMN IF EXISTS "ClipReviewEnabled";
                """);

            migrationBuilder.Sql("""
                ALTER TABLE "SiteSettings"
                DROP COLUMN IF EXISTS "ClipSubmissionDisabledMessage";
                """);

            migrationBuilder.Sql("""
                ALTER TABLE "SiteSettings"
                DROP COLUMN IF EXISTS "ClipSubmissionsEnabled";
                """);
        }
    }
}
