using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Elecciones.Database.Migrations
{
    /// <inheritdoc />
    public partial class AddConfigBancas : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterDatabase(
                collation: "Modern_Spanish_CI_AS");

            migrationBuilder.AddColumn<string>(
                name: "Color",
                table: "AgrupacionesPoliticas",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "LogoUrl",
                table: "AgrupacionesPoliticas",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "NombreCorto",
                table: "AgrupacionesPoliticas",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "ComposicionBancadas",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    AgrupacionPoliticaId = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    Camara = table.Column<int>(type: "int", nullable: false),
                    BancasTotales = table.Column<int>(type: "int", nullable: false),
                    BancasEnJuego = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ComposicionBancadas", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ComposicionBancadas_AgrupacionesPoliticas_AgrupacionPoliticaId",
                        column: x => x.AgrupacionPoliticaId,
                        principalTable: "AgrupacionesPoliticas",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "OcupantesBancas",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ComposicionBancadaId = table.Column<int>(type: "int", nullable: false),
                    NombreOcupante = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    FotoUrl = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Periodo = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OcupantesBancas", x => x.Id);
                    table.ForeignKey(
                        name: "FK_OcupantesBancas_ComposicionBancadas_ComposicionBancadaId",
                        column: x => x.ComposicionBancadaId,
                        principalTable: "ComposicionBancadas",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_ComposicionBancadas_AgrupacionPoliticaId",
                table: "ComposicionBancadas",
                column: "AgrupacionPoliticaId");

            migrationBuilder.CreateIndex(
                name: "IX_OcupantesBancas_ComposicionBancadaId",
                table: "OcupantesBancas",
                column: "ComposicionBancadaId");
        }

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

            migrationBuilder.DropTable(
                name: "ComposicionBancadas");

            migrationBuilder.DropColumn(
                name: "Color",
                table: "AgrupacionesPoliticas");

            migrationBuilder.DropColumn(
                name: "LogoUrl",
                table: "AgrupacionesPoliticas");

            migrationBuilder.DropColumn(
                name: "NombreCorto",
                table: "AgrupacionesPoliticas");

            migrationBuilder.AlterDatabase(
                oldCollation: "Modern_Spanish_CI_AS");
        }
    }
}
