using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace MiniMarket.Web.Migrations
{
///
public partial class AddGastosYTotalCaja : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn(
name: "TotalGastos",
table: "AperturasCaja",
type: "decimal(18,2)",
nullable: false,
defaultValue: 0m);
migrationBuilder.CreateTable(
name: "Gastos",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Concepto = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false),
Monto = table.Column(type: "decimal(18,2)", nullable: false),
Fecha = table.Column(type: "datetime2", nullable: false),
UsuarioId = table.Column(type: "nvarchar(450)", nullable: true),
AperturaCajaId = table.Column(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Gastos", x => x.Id);
table.ForeignKey(
name: "FK_Gastos_AperturasCaja_AperturaCajaId",
column: x => x.AperturaCajaId,
principalTable: "AperturasCaja",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Gastos_AspNetUsers_UsuarioId",
column: x => x.UsuarioId,
principalTable: "AspNetUsers",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Gastos_AperturaCajaId",
table: "Gastos",
column: "AperturaCajaId");
migrationBuilder.CreateIndex(
name: "IX_Gastos_UsuarioId",
table: "Gastos",
column: "UsuarioId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Gastos");
migrationBuilder.DropColumn(
name: "TotalGastos",
table: "AperturasCaja");
}
}
}