168 lines
8.0 KiB
C#
168 lines
8.0 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Distribution.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddRideReconciliation : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "RideCloseSummaries",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_RideId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
ExpectedCash = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
ActualCash = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
CashVariance = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
FK_ClosedByUserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
ClosedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_RideCloseSummaries", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_RideCloseSummaries_DeliveryRuns_FK_RideId",
|
|
column: x => x.FK_RideId,
|
|
principalTable: "DeliveryRuns",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_RideCloseSummaries_Users_FK_ClosedByUserId",
|
|
column: x => x.FK_ClosedByUserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "RideItemCounts",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_RideId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_ItemId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
PhysicalQuantity = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_RideItemCounts", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_RideItemCounts_DeliveryRuns_FK_RideId",
|
|
column: x => x.FK_RideId,
|
|
principalTable: "DeliveryRuns",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_RideItemCounts_Items_FK_ItemId",
|
|
column: x => x.FK_ItemId,
|
|
principalTable: "Items",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "RideVariances",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_RideId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_ItemId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
IsCash = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
ExpectedQuantity = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
ActualQuantity = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
VarianceQuantity = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
ReasonCode = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Status = table.Column<int>(type: "int", nullable: false),
|
|
FK_ResolvedByUserId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
ResolvedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_RideVariances", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_RideVariances_DeliveryRuns_FK_RideId",
|
|
column: x => x.FK_RideId,
|
|
principalTable: "DeliveryRuns",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_RideVariances_Items_FK_ItemId",
|
|
column: x => x.FK_ItemId,
|
|
principalTable: "Items",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_RideVariances_Users_FK_ResolvedByUserId",
|
|
column: x => x.FK_ResolvedByUserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_RideCloseSummaries_FK_ClosedByUserId",
|
|
table: "RideCloseSummaries",
|
|
column: "FK_ClosedByUserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_RideCloseSummaries_FK_RideId",
|
|
table: "RideCloseSummaries",
|
|
column: "FK_RideId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_RideItemCounts_FK_ItemId",
|
|
table: "RideItemCounts",
|
|
column: "FK_ItemId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_RideItemCounts_FK_RideId",
|
|
table: "RideItemCounts",
|
|
column: "FK_RideId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_RideVariances_FK_ItemId",
|
|
table: "RideVariances",
|
|
column: "FK_ItemId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_RideVariances_FK_ResolvedByUserId",
|
|
table: "RideVariances",
|
|
column: "FK_ResolvedByUserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_RideVariances_FK_RideId",
|
|
table: "RideVariances",
|
|
column: "FK_RideId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "RideCloseSummaries");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "RideItemCounts");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "RideVariances");
|
|
}
|
|
}
|
|
}
|