228 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			228 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using Microsoft.EntityFrameworkCore.Migrations;
 | |
| 
 | |
| #nullable disable
 | |
| 
 | |
| namespace Elecciones.Database.Migrations
 | |
| {
 | |
|     /// <inheritdoc />
 | |
|     public partial class InitialSchema : 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: "EstadosRecuentosGenerales",
 | |
|                 columns: table => new
 | |
|                 {
 | |
|                     AmbitoGeograficoId = table.Column<int>(type: "int", 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)
 | |
|                 },
 | |
|                 constraints: table =>
 | |
|                 {
 | |
|                     table.PrimaryKey("PK_EstadosRecuentosGenerales", x => x.AmbitoGeograficoId);
 | |
|                 });
 | |
| 
 | |
|             migrationBuilder.CreateTable(
 | |
|                 name: "ResumenesVotos",
 | |
|                 columns: table => new
 | |
|                 {
 | |
|                     Id = table.Column<int>(type: "int", nullable: false)
 | |
|                         .Annotation("SqlServer:Identity", "1, 1"),
 | |
|                     AmbitoGeograficoId = table.Column<int>(type: "int", nullable: false),
 | |
|                     AgrupacionPoliticaId = table.Column<string>(type: "nvarchar(max)", nullable: false),
 | |
|                     Votos = table.Column<long>(type: "bigint", nullable: false),
 | |
|                     VotosPorcentaje = table.Column<decimal>(type: "decimal(5,2)", precision: 5, scale: 2, nullable: false)
 | |
|                 },
 | |
|                 constraints: table =>
 | |
|                 {
 | |
|                     table.PrimaryKey("PK_ResumenesVotos", x => x.Id);
 | |
|                 });
 | |
| 
 | |
|             migrationBuilder.CreateTable(
 | |
|                 name: "Telegramas",
 | |
|                 columns: table => new
 | |
|                 {
 | |
|                     Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
 | |
|                     AmbitoGeograficoId = table.Column<int>(type: "int", nullable: false),
 | |
|                     ContenidoBase64 = table.Column<string>(type: "nvarchar(max)", nullable: false),
 | |
|                     FechaEscaneo = table.Column<DateTime>(type: "datetime2", nullable: false),
 | |
|                     FechaTotalizacion = table.Column<DateTime>(type: "datetime2", nullable: false)
 | |
|                 },
 | |
|                 constraints: table =>
 | |
|                 {
 | |
|                     table.PrimaryKey("PK_Telegramas", 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: "ProyeccionesBancas",
 | |
|                 columns: table => new
 | |
|                 {
 | |
|                     Id = table.Column<int>(type: "int", nullable: false)
 | |
|                         .Annotation("SqlServer:Identity", "1, 1"),
 | |
|                     AmbitoGeograficoId = table.Column<int>(type: "int", nullable: false),
 | |
|                     AgrupacionPoliticaId = table.Column<string>(type: "nvarchar(450)", nullable: false),
 | |
|                     NroBancas = table.Column<int>(type: "int", nullable: false)
 | |
|                 },
 | |
|                 constraints: table =>
 | |
|                 {
 | |
|                     table.PrimaryKey("PK_ProyeccionesBancas", x => x.Id);
 | |
|                     table.ForeignKey(
 | |
|                         name: "FK_ProyeccionesBancas_AgrupacionesPoliticas_AgrupacionPoliticaId",
 | |
|                         column: x => x.AgrupacionPoliticaId,
 | |
|                         principalTable: "AgrupacionesPoliticas",
 | |
|                         principalColumn: "Id",
 | |
|                         onDelete: ReferentialAction.Cascade);
 | |
|                     table.ForeignKey(
 | |
|                         name: "FK_ProyeccionesBancas_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_ProyeccionesBancas_AgrupacionPoliticaId",
 | |
|                 table: "ProyeccionesBancas",
 | |
|                 column: "AgrupacionPoliticaId");
 | |
| 
 | |
|             migrationBuilder.CreateIndex(
 | |
|                 name: "IX_ProyeccionesBancas_AmbitoGeograficoId",
 | |
|                 table: "ProyeccionesBancas",
 | |
|                 column: "AmbitoGeograficoId");
 | |
| 
 | |
|             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: "EstadosRecuentosGenerales");
 | |
| 
 | |
|             migrationBuilder.DropTable(
 | |
|                 name: "ProyeccionesBancas");
 | |
| 
 | |
|             migrationBuilder.DropTable(
 | |
|                 name: "ResultadosVotos");
 | |
| 
 | |
|             migrationBuilder.DropTable(
 | |
|                 name: "ResumenesVotos");
 | |
| 
 | |
|             migrationBuilder.DropTable(
 | |
|                 name: "Telegramas");
 | |
| 
 | |
|             migrationBuilder.DropTable(
 | |
|                 name: "AgrupacionesPoliticas");
 | |
| 
 | |
|             migrationBuilder.DropTable(
 | |
|                 name: "AmbitosGeograficos");
 | |
|         }
 | |
|     }
 | |
| }
 |