using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace TeleWave.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class DropDeadBumperSettings : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            // Значение 0 (прежняя «ротация») из перечисления убрано: курсора ротации больше нет,
            // и выбор молча вырождался в случайный. Переводим такие каналы на выбор по весам.
            migrationBuilder.Sql(
                """UPDATE "Channels" SET "BumperSelection" = 3 WHERE "BumperSelection" = 0;"""
            );

            migrationBuilder.DropColumn(name: "BumperEpisodeChangeChance", table: "Channels");

            migrationBuilder.DropColumn(name: "BumperMinIntervalMinutes", table: "Channels");

            migrationBuilder.DropColumn(name: "BumperShowChangeChance", table: "Channels");

            migrationBuilder.DropColumn(name: "NextBumperIndex", table: "Channels");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<double>(
                name: "BumperEpisodeChangeChance",
                table: "Channels",
                type: "double precision",
                nullable: false,
                defaultValue: 0.0
            );

            migrationBuilder.AddColumn<int>(
                name: "BumperMinIntervalMinutes",
                table: "Channels",
                type: "integer",
                nullable: false,
                defaultValue: 0
            );

            migrationBuilder.AddColumn<double>(
                name: "BumperShowChangeChance",
                table: "Channels",
                type: "double precision",
                nullable: false,
                defaultValue: 0.0
            );

            migrationBuilder.AddColumn<int>(
                name: "NextBumperIndex",
                table: "Channels",
                type: "integer",
                nullable: false,
                defaultValue: 0
            );
        }
    }
}
