6d8b6b3e59
Implemented DeliveryTask, Payment, and Sale entities with full CRUD, business logic, and API endpoints. Updated Order/OrderItem for sale linkage and fulfillment tracking. Registered new DbSets and DI services. Revised documentation for delivery, sale, and payment workflows.
237 lines
10 KiB
C#
237 lines
10 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Distribution.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class payment : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<Guid>(
|
|
name: "FK_SaleId",
|
|
table: "Orders",
|
|
type: "char(36)",
|
|
nullable: false,
|
|
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
|
|
collation: "ascii_general_ci");
|
|
|
|
migrationBuilder.AddColumn<DateTime>(
|
|
name: "FulfilledAt",
|
|
table: "Orders",
|
|
type: "datetime(6)",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "Status",
|
|
table: "Orders",
|
|
type: "int",
|
|
nullable: false,
|
|
defaultValue: 0);
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "QuantityFulfilled",
|
|
table: "OrderItems",
|
|
type: "int",
|
|
nullable: false,
|
|
defaultValue: 0);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "DeliveryTasks",
|
|
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_OrderId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Sequence = table.Column<int>(type: "int", nullable: false),
|
|
Status = table.Column<int>(type: "int", nullable: false),
|
|
CustomerConfirmed = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
ConfirmedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
Note = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_DeliveryTasks", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_DeliveryTasks_DeliveryRuns_FK_RideId",
|
|
column: x => x.FK_RideId,
|
|
principalTable: "DeliveryRuns",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_DeliveryTasks_Orders_FK_OrderId",
|
|
column: x => x.FK_OrderId,
|
|
principalTable: "Orders",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Sales",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
SaleDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
FK_StoreId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
CreatedByUserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_RideId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
TotalAmount = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
Status = table.Column<int>(type: "int", nullable: false),
|
|
PaymentStatus = table.Column<int>(type: "int", nullable: false),
|
|
FulfillImmediately = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
CompletedAt = 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_Sales", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Sales_DeliveryRuns_FK_RideId",
|
|
column: x => x.FK_RideId,
|
|
principalTable: "DeliveryRuns",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_Sales_Stores_FK_StoreId",
|
|
column: x => x.FK_StoreId,
|
|
principalTable: "Stores",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_Sales_Users_CreatedByUserId",
|
|
column: x => x.CreatedByUserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Payments",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_SaleId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_StoreId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Amount = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
Method = table.Column<int>(type: "int", nullable: false),
|
|
CollectedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
CollectedBy = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Payments", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Payments_Sales_FK_SaleId",
|
|
column: x => x.FK_SaleId,
|
|
principalTable: "Sales",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Payments_Stores_FK_StoreId",
|
|
column: x => x.FK_StoreId,
|
|
principalTable: "Stores",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Orders_FK_SaleId",
|
|
table: "Orders",
|
|
column: "FK_SaleId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeliveryTasks_FK_OrderId",
|
|
table: "DeliveryTasks",
|
|
column: "FK_OrderId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeliveryTasks_FK_RideId",
|
|
table: "DeliveryTasks",
|
|
column: "FK_RideId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Payments_FK_SaleId",
|
|
table: "Payments",
|
|
column: "FK_SaleId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Payments_FK_StoreId",
|
|
table: "Payments",
|
|
column: "FK_StoreId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Sales_CreatedByUserId",
|
|
table: "Sales",
|
|
column: "CreatedByUserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Sales_FK_RideId",
|
|
table: "Sales",
|
|
column: "FK_RideId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Sales_FK_StoreId",
|
|
table: "Sales",
|
|
column: "FK_StoreId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_Orders_Sales_FK_SaleId",
|
|
table: "Orders",
|
|
column: "FK_SaleId",
|
|
principalTable: "Sales",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_Orders_Sales_FK_SaleId",
|
|
table: "Orders");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "DeliveryTasks");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Payments");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Sales");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Orders_FK_SaleId",
|
|
table: "Orders");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "FK_SaleId",
|
|
table: "Orders");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "FulfilledAt",
|
|
table: "Orders");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "Status",
|
|
table: "Orders");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "QuantityFulfilled",
|
|
table: "OrderItems");
|
|
}
|
|
}
|
|
}
|