feat: Diseño del esquema de BD y configuración de Entity Framework Core
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Elecciones.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AgrupacionesPoliticas",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
IdTelegrama = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Nombre = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AgrupacionesPoliticas", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AmbitosGeograficos",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Nombre = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
NivelId = table.Column<int>(type: "int", nullable: false),
|
||||
DistritoId = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
SeccionProvincialId = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
SeccionId = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
MunicipioId = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
CircuitoId = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
EstablecimientoId = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
MesaId = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AmbitosGeograficos", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "EstadosRecuentos",
|
||||
columns: table => new
|
||||
{
|
||||
AmbitoGeograficoId = table.Column<int>(type: "int", nullable: false),
|
||||
FechaTotalizacion = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
MesasEsperadas = table.Column<int>(type: "int", nullable: false),
|
||||
MesasTotalizadas = table.Column<int>(type: "int", nullable: false),
|
||||
MesasTotalizadasPorcentaje = table.Column<decimal>(type: "decimal(5,2)", precision: 5, scale: 2, nullable: false),
|
||||
CantidadElectores = table.Column<int>(type: "int", nullable: false),
|
||||
CantidadVotantes = table.Column<int>(type: "int", nullable: false),
|
||||
ParticipacionPorcentaje = table.Column<decimal>(type: "decimal(5,2)", precision: 5, scale: 2, nullable: false),
|
||||
VotosNulos = table.Column<long>(type: "bigint", nullable: false),
|
||||
VotosEnBlanco = table.Column<long>(type: "bigint", nullable: false),
|
||||
VotosRecurridos = table.Column<long>(type: "bigint", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_EstadosRecuentos", x => x.AmbitoGeograficoId);
|
||||
table.ForeignKey(
|
||||
name: "FK_EstadosRecuentos_AmbitosGeograficos_AmbitoGeograficoId",
|
||||
column: x => x.AmbitoGeograficoId,
|
||||
principalTable: "AmbitosGeograficos",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ResultadosVotos",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
AmbitoGeograficoId = table.Column<int>(type: "int", nullable: false),
|
||||
AgrupacionPoliticaId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
CantidadVotos = table.Column<long>(type: "bigint", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ResultadosVotos", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ResultadosVotos_AgrupacionesPoliticas_AgrupacionPoliticaId",
|
||||
column: x => x.AgrupacionPoliticaId,
|
||||
principalTable: "AgrupacionesPoliticas",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ResultadosVotos_AmbitosGeograficos_AmbitoGeograficoId",
|
||||
column: x => x.AmbitoGeograficoId,
|
||||
principalTable: "AmbitosGeograficos",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ResultadosVotos_AgrupacionPoliticaId",
|
||||
table: "ResultadosVotos",
|
||||
column: "AgrupacionPoliticaId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ResultadosVotos_AmbitoGeograficoId_AgrupacionPoliticaId",
|
||||
table: "ResultadosVotos",
|
||||
columns: new[] { "AmbitoGeograficoId", "AgrupacionPoliticaId" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "EstadosRecuentos");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ResultadosVotos");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AgrupacionesPoliticas");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AmbitosGeograficos");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user