ac3f34e4f3
Added .gitignore, solution, and project files for .NET 10. Introduced AGENTS.md and PLAN.md for guidelines and planning. Implemented appsettings.json, launchSettings.json, and MySQL config. Created AppDBContext and all domain models with composite keys. Added IUnitOfWork and EFUnitOfWork. Structured feature folders for Region, Route, Vehicle, Store, Warehouse, and Order with DTOs, repositories, services, and controllers. Added initial EF Core migrations and sample HTTP request. Registered dependencies and enabled OpenAPI in development.
279 lines
12 KiB
C#
279 lines
12 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Distribution.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class init : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AlterDatabase()
|
|
.Annotation("MySQL:Charset", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Items",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", 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_Items", x => x.Id);
|
|
})
|
|
.Annotation("MySQL:Charset", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Regions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false),
|
|
Name = table.Column<string>(type: "longtext", 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_Regions", x => x.Id);
|
|
})
|
|
.Annotation("MySQL:Charset", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Routes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false),
|
|
RouteName = table.Column<string>(type: "longtext", nullable: false),
|
|
StartPoint = table.Column<string>(type: "longtext", nullable: false),
|
|
EndPoint = table.Column<string>(type: "longtext", nullable: false),
|
|
Length = table.Column<decimal>(type: "decimal(18,2)", 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_Routes", x => x.Id);
|
|
})
|
|
.Annotation("MySQL:Charset", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SaleRoutes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", 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_SaleRoutes", x => x.Id);
|
|
})
|
|
.Annotation("MySQL:Charset", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Stores",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false),
|
|
OwnerName = table.Column<string>(type: "longtext", nullable: false),
|
|
StoreName = table.Column<string>(type: "longtext", nullable: false),
|
|
StoreAddress = table.Column<string>(type: "longtext", nullable: false),
|
|
Latitude = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
Longitude = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
OneTimeAmount = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
CreditAmount = table.Column<decimal>(type: "decimal(18,2)", 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_Stores", x => x.Id);
|
|
})
|
|
.Annotation("MySQL:Charset", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Vehicles",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false),
|
|
RegNumber = table.Column<string>(type: "longtext", nullable: false),
|
|
NumberPlate = table.Column<string>(type: "longtext", nullable: false),
|
|
Type = table.Column<int>(type: "int", 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_Vehicles", x => x.Id);
|
|
})
|
|
.Annotation("MySQL:Charset", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Orders",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false),
|
|
OrderDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
FK_StoreId = table.Column<Guid>(type: "char(36)", nullable: false),
|
|
TotalAmount = table.Column<decimal>(type: "decimal(18,2)", 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_Orders", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Orders_Stores_FK_StoreId",
|
|
column: x => x.FK_StoreId,
|
|
principalTable: "Stores",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySQL:Charset", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "DeliveryRuns",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false),
|
|
FK_VehicleId = table.Column<Guid>(type: "char(36)", nullable: false),
|
|
Meterstart = table.Column<int>(type: "int", nullable: false),
|
|
Meterend = table.Column<int>(type: "int", nullable: false),
|
|
FK_RouteId = table.Column<Guid>(type: "char(36)", 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_DeliveryRuns", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_DeliveryRuns_Routes_FK_RouteId",
|
|
column: x => x.FK_RouteId,
|
|
principalTable: "Routes",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_DeliveryRuns_Vehicles_FK_VehicleId",
|
|
column: x => x.FK_VehicleId,
|
|
principalTable: "Vehicles",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySQL:Charset", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Warehouses",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false),
|
|
Name = table.Column<string>(type: "longtext", nullable: false),
|
|
Location = table.Column<string>(type: "longtext", nullable: false),
|
|
type = table.Column<int>(type: "int", nullable: false),
|
|
VehicleId = table.Column<Guid>(type: "char(36)", 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_Warehouses", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Warehouses_Vehicles_VehicleId",
|
|
column: x => x.VehicleId,
|
|
principalTable: "Vehicles",
|
|
principalColumn: "Id");
|
|
})
|
|
.Annotation("MySQL:Charset", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "OrderItems",
|
|
columns: table => new
|
|
{
|
|
FK_OrderId = table.Column<Guid>(type: "char(36)", nullable: false),
|
|
FK_ItemId = table.Column<Guid>(type: "char(36)", nullable: false),
|
|
Quantity = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_OrderItems", x => new { x.FK_OrderId, x.FK_ItemId });
|
|
table.ForeignKey(
|
|
name: "FK_OrderItems_Items_FK_ItemId",
|
|
column: x => x.FK_ItemId,
|
|
principalTable: "Items",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_OrderItems_Orders_FK_OrderId",
|
|
column: x => x.FK_OrderId,
|
|
principalTable: "Orders",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySQL:Charset", "utf8mb4");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeliveryRuns_FK_RouteId",
|
|
table: "DeliveryRuns",
|
|
column: "FK_RouteId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeliveryRuns_FK_VehicleId",
|
|
table: "DeliveryRuns",
|
|
column: "FK_VehicleId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_OrderItems_FK_ItemId",
|
|
table: "OrderItems",
|
|
column: "FK_ItemId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Orders_FK_StoreId",
|
|
table: "Orders",
|
|
column: "FK_StoreId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Warehouses_VehicleId",
|
|
table: "Warehouses",
|
|
column: "VehicleId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "DeliveryRuns");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "OrderItems");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Regions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SaleRoutes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Warehouses");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Routes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Items");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Orders");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Vehicles");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Stores");
|
|
}
|
|
}
|
|
}
|