using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace TeleWave.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class BumperFilesAndJingles : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<string>(
                name: "BumperBackgroundExtension",
                table: "Channels",
                type: "text",
                nullable: true
            );

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

            migrationBuilder.AddColumn<string>(
                name: "BumperMusicExtension",
                table: "Channels",
                type: "text",
                nullable: true
            );

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

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

            migrationBuilder.CreateTable(
                name: "ChannelJingle",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    ChannelId = table.Column<Guid>(type: "uuid", nullable: false),
                    MediaAssetId = table.Column<Guid>(type: "uuid", nullable: false),
                    Position = table.Column<int>(type: "integer", nullable: false),
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ChannelJingle", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ChannelJingle_Channels_ChannelId",
                        column: x => x.ChannelId,
                        principalTable: "Channels",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                }
            );

            migrationBuilder.CreateIndex(
                name: "IX_ChannelJingle_ChannelId_Position",
                table: "ChannelJingle",
                columns: new[] { "ChannelId", "Position" }
            );
        }

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

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

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

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

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

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