//<auto-generated />
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional

namespace Database.Migrations
{
    /// <inheritdoc />
    public partial class Add_CustomEventCategory : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<Guid>(
                name: "CustomEventCategoryId",
                schema: "dbo",
                table: "CustomEvents",
                type: "uniqueidentifier",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "CustomEventCategory",
                schema: "dbo",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    AllianceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
                    IsPointsEvent = table.Column<bool>(type: "bit", nullable: false),
                    IsParticipationEvent = table.Column<bool>(type: "bit", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CustomEventCategory", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CustomEventCategory_Alliances_AllianceId",
                        column: x => x.AllianceId,
                        principalSchema: "dbo",
                        principalTable: "Alliances",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_CustomEvents_CustomEventCategoryId",
                schema: "dbo",
                table: "CustomEvents",
                column: "CustomEventCategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_CustomEventCategory_AllianceId",
                schema: "dbo",
                table: "CustomEventCategory",
                column: "AllianceId");

            migrationBuilder.AddForeignKey(
                name: "FK_CustomEvents_CustomEventCategory_CustomEventCategoryId",
                schema: "dbo",
                table: "CustomEvents",
                column: "CustomEventCategoryId",
                principalSchema: "dbo",
                principalTable: "CustomEventCategory",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_CustomEvents_CustomEventCategory_CustomEventCategoryId",
                schema: "dbo",
                table: "CustomEvents");

            migrationBuilder.DropTable(
                name: "CustomEventCategory",
                schema: "dbo");

            migrationBuilder.DropIndex(
                name: "IX_CustomEvents_CustomEventCategoryId",
                schema: "dbo",
                table: "CustomEvents");

            migrationBuilder.DropColumn(
                name: "CustomEventCategoryId",
                schema: "dbo",
                table: "CustomEvents");
        }
    }
}
