using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace TeleWave.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class ChannelShowPreferredHours : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<int>(
                name: "PreferredWeightMultiplier",
                table: "ChannelShow",
                type: "integer",
                nullable: false,
                defaultValue: 3
            );

            migrationBuilder.CreateTable(
                name: "ChannelShowHour",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    ChannelShowId = table.Column<Guid>(type: "uuid", nullable: false),
                    StartHour = table.Column<int>(type: "integer", nullable: false),
                    EndHour = table.Column<int>(type: "integer", nullable: false),
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ChannelShowHour", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ChannelShowHour_ChannelShow_ChannelShowId",
                        column: x => x.ChannelShowId,
                        principalTable: "ChannelShow",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                }
            );

            migrationBuilder.CreateIndex(
                name: "IX_ChannelShowHour_ChannelShowId",
                table: "ChannelShowHour",
                column: "ChannelShowId"
            );
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(name: "ChannelShowHour");

            migrationBuilder.DropColumn(name: "PreferredWeightMultiplier", table: "ChannelShow");
        }
    }
}
