using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Elecciones.Database.Migrations { /// public partial class InitialSchema : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "AgrupacionesPoliticas", columns: table => new { Id = table.Column(type: "nvarchar(450)", nullable: false), IdTelegrama = table.Column(type: "nvarchar(max)", nullable: false), Nombre = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AgrupacionesPoliticas", x => x.Id); }); migrationBuilder.CreateTable( name: "AmbitosGeograficos", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Nombre = table.Column(type: "nvarchar(max)", nullable: false), NivelId = table.Column(type: "int", nullable: false), DistritoId = table.Column(type: "nvarchar(max)", nullable: true), SeccionProvincialId = table.Column(type: "nvarchar(max)", nullable: true), SeccionId = table.Column(type: "nvarchar(max)", nullable: true), MunicipioId = table.Column(type: "nvarchar(max)", nullable: true), CircuitoId = table.Column(type: "nvarchar(max)", nullable: true), EstablecimientoId = table.Column(type: "nvarchar(max)", nullable: true), MesaId = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_AmbitosGeograficos", x => x.Id); }); migrationBuilder.CreateTable( name: "EstadosRecuentosGenerales", columns: table => new { AmbitoGeograficoId = table.Column(type: "int", nullable: false), MesasEsperadas = table.Column(type: "int", nullable: false), MesasTotalizadas = table.Column(type: "int", nullable: false), MesasTotalizadasPorcentaje = table.Column(type: "decimal(5,2)", precision: 5, scale: 2, nullable: false), CantidadElectores = table.Column(type: "int", nullable: false), CantidadVotantes = table.Column(type: "int", nullable: false), ParticipacionPorcentaje = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), AmbitoGeograficoId = table.Column(type: "int", nullable: false), AgrupacionPoliticaId = table.Column(type: "nvarchar(max)", nullable: false), Votos = table.Column(type: "bigint", nullable: false), VotosPorcentaje = table.Column(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(type: "nvarchar(450)", nullable: false), AmbitoGeograficoId = table.Column(type: "int", nullable: false), ContenidoBase64 = table.Column(type: "nvarchar(max)", nullable: false), FechaEscaneo = table.Column(type: "datetime2", nullable: false), FechaTotalizacion = table.Column(type: "datetime2", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Telegramas", x => x.Id); }); migrationBuilder.CreateTable( name: "EstadosRecuentos", columns: table => new { AmbitoGeograficoId = table.Column(type: "int", nullable: false), FechaTotalizacion = table.Column(type: "datetime2", nullable: false), MesasEsperadas = table.Column(type: "int", nullable: false), MesasTotalizadas = table.Column(type: "int", nullable: false), MesasTotalizadasPorcentaje = table.Column(type: "decimal(5,2)", precision: 5, scale: 2, nullable: false), CantidadElectores = table.Column(type: "int", nullable: false), CantidadVotantes = table.Column(type: "int", nullable: false), ParticipacionPorcentaje = table.Column(type: "decimal(5,2)", precision: 5, scale: 2, nullable: false), VotosNulos = table.Column(type: "bigint", nullable: false), VotosEnBlanco = table.Column(type: "bigint", nullable: false), VotosRecurridos = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), AmbitoGeograficoId = table.Column(type: "int", nullable: false), AgrupacionPoliticaId = table.Column(type: "nvarchar(450)", nullable: false), NroBancas = table.Column(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(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), AmbitoGeograficoId = table.Column(type: "int", nullable: false), AgrupacionPoliticaId = table.Column(type: "nvarchar(450)", nullable: false), CantidadVotos = table.Column(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); } /// 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"); } } }