1369 lines
68 KiB
C#
1369 lines
68 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
|
|
|
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: "Brands",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ExternalErpId = table.Column<int>(type: "int", 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_Brands", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Categories",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ExternalErpId = table.Column<int>(type: "int", nullable: true),
|
|
AllowCustomerReturn = table.Column<bool>(type: "tinyint(1)", 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_Categories", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "DriverComplianceConfigs",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
EnforceLicenseExpiry = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
EnforceMedicalClearance = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
UpdatedBy = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_DriverComplianceConfigs", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Permissions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Code = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Description = table.Column<string>(type: "longtext", nullable: false)
|
|
.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_Permissions", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Regions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
|
.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_Regions", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Roles",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Level = 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_Roles", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SaleRoutes",
|
|
columns: table => new
|
|
{
|
|
Id = 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_SaleRoutes", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Suppliers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ContactInfo = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
PerformanceScore = table.Column<decimal>(type: "decimal(65,30)", 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_Suppliers", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Uoms",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ExternalErpId = table.Column<int>(type: "int", 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_Uoms", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SubCategories",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
FK_CategoryId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
ExternalErpId = table.Column<int>(type: "int", 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_SubCategories", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_SubCategories_Categories_FK_CategoryId",
|
|
column: x => x.FK_CategoryId,
|
|
principalTable: "Categories",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "PriceLists",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
FK_RegionId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
EffectiveFrom = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
EffectiveTo = 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_PriceLists", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_PriceLists_Regions_FK_RegionId",
|
|
column: x => x.FK_RegionId,
|
|
principalTable: "Regions",
|
|
principalColumn: "Id");
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Routes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
RouteName = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
StartPoint = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
EndPoint = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Length = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
FK_RegionId = 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_Routes", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Routes_Regions_FK_RegionId",
|
|
column: x => x.FK_RegionId,
|
|
principalTable: "Regions",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "RolePermissions",
|
|
columns: table => new
|
|
{
|
|
FK_RoleId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_PermissionId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Id = 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_RolePermissions", x => new { x.FK_RoleId, x.FK_PermissionId });
|
|
table.ForeignKey(
|
|
name: "FK_RolePermissions_Permissions_FK_PermissionId",
|
|
column: x => x.FK_PermissionId,
|
|
principalTable: "Permissions",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_RolePermissions_Roles_FK_RoleId",
|
|
column: x => x.FK_RoleId,
|
|
principalTable: "Roles",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Users",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Username = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
PasswordHash = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
FullName = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
FK_RoleId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_ReportsToUserId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
UpdatedAt = 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_Users", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Users_Roles_FK_RoleId",
|
|
column: x => x.FK_RoleId,
|
|
principalTable: "Roles",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Users_Users_FK_ReportsToUserId",
|
|
column: x => x.FK_ReportsToUserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Items",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Sku = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Description = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
FK_CategoryId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_SubCategoryId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
FK_BrandId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
FK_BaseUomId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
SalePrice = table.Column<decimal>(type: "decimal(65,30)", nullable: true),
|
|
CostPrice = table.Column<decimal>(type: "decimal(65,30)", nullable: true),
|
|
SyncSource = table.Column<int>(type: "int", nullable: false),
|
|
ExternalErpItemId = table.Column<int>(type: "int", nullable: true),
|
|
LastSyncedAt = 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_Items", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Items_Brands_FK_BrandId",
|
|
column: x => x.FK_BrandId,
|
|
principalTable: "Brands",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_Items_Categories_FK_CategoryId",
|
|
column: x => x.FK_CategoryId,
|
|
principalTable: "Categories",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Items_SubCategories_FK_SubCategoryId",
|
|
column: x => x.FK_SubCategoryId,
|
|
principalTable: "SubCategories",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_Items_Uoms_FK_BaseUomId",
|
|
column: x => x.FK_BaseUomId,
|
|
principalTable: "Uoms",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Stores",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
OwnerName = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
StoreName = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
StoreAddress = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Latitude = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
Longitude = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
OneTimeAmount = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
CreditAmount = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
CreditLimit = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
OutstandingBalance = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
Segment = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
KycStatus = table.Column<int>(type: "int", nullable: false),
|
|
FK_RouteId = 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_Stores", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Stores_Routes_FK_RouteId",
|
|
column: x => x.FK_RouteId,
|
|
principalTable: "Routes",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "DriverProfiles",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
LicenseNumber = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
LicenseExpiry = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
MedicalClearanceExpiry = 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_DriverProfiles", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_DriverProfiles_Users_FK_UserId",
|
|
column: x => x.FK_UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "UserRegionScopes",
|
|
columns: table => new
|
|
{
|
|
FK_UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_RegionId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Id = 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_UserRegionScopes", x => new { x.FK_UserId, x.FK_RegionId });
|
|
table.ForeignKey(
|
|
name: "FK_UserRegionScopes_Regions_FK_RegionId",
|
|
column: x => x.FK_RegionId,
|
|
principalTable: "Regions",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_UserRegionScopes_Users_FK_UserId",
|
|
column: x => x.FK_UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "UserRouteScopes",
|
|
columns: table => new
|
|
{
|
|
FK_UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_RouteId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Id = 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_UserRouteScopes", x => new { x.FK_UserId, x.FK_RouteId });
|
|
table.ForeignKey(
|
|
name: "FK_UserRouteScopes_Routes_FK_RouteId",
|
|
column: x => x.FK_RouteId,
|
|
principalTable: "Routes",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_UserRouteScopes_Users_FK_UserId",
|
|
column: x => x.FK_UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "PriceListItems",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_PriceListId = 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"),
|
|
Price = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
MinPrice = table.Column<decimal>(type: "decimal(65,30)", 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_PriceListItems", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_PriceListItems_Items_FK_ItemId",
|
|
column: x => x.FK_ItemId,
|
|
principalTable: "Items",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_PriceListItems_PriceLists_FK_PriceListId",
|
|
column: x => x.FK_PriceListId,
|
|
principalTable: "PriceLists",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Schemes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
RuleType = table.Column<int>(type: "int", nullable: false),
|
|
RuleConfig = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
FK_TriggerItemId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
TriggerQty = table.Column<int>(type: "int", nullable: true),
|
|
FK_FreeItemId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
FreeQty = table.Column<decimal>(type: "decimal(65,30)", nullable: true),
|
|
FK_RegionId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
RegionId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
EligibleSegment = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
DateRangeFrom = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
DateRangeTo = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
AgentLimitExempt = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
BaselineExpectedSales = table.Column<decimal>(type: "decimal(65,30)", 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_Schemes", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Schemes_Items_FK_FreeItemId",
|
|
column: x => x.FK_FreeItemId,
|
|
principalTable: "Items",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_Schemes_Items_FK_TriggerItemId",
|
|
column: x => x.FK_TriggerItemId,
|
|
principalTable: "Items",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_Schemes_Regions_RegionId",
|
|
column: x => x.RegionId,
|
|
principalTable: "Regions",
|
|
principalColumn: "Id");
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "StockBalances",
|
|
columns: table => new
|
|
{
|
|
Id = 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"),
|
|
LocationId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
LocationType = table.Column<int>(type: "int", nullable: false),
|
|
Quantity = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_StockBalances", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_StockBalances_Items_FK_ItemId",
|
|
column: x => x.FK_ItemId,
|
|
principalTable: "Items",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "StockMovements",
|
|
columns: table => new
|
|
{
|
|
Id = 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"),
|
|
FromLocationId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
FromLocationType = table.Column<int>(type: "int", nullable: true),
|
|
ToLocationId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
ToLocationType = table.Column<int>(type: "int", nullable: true),
|
|
Quantity = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
Type = table.Column<int>(type: "int", nullable: false),
|
|
ReasonCode = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ReferenceId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
CreatedBy = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_StockMovements", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_StockMovements_Items_FK_ItemId",
|
|
column: x => x.FK_ItemId,
|
|
principalTable: "Items",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "UomConversions",
|
|
columns: table => new
|
|
{
|
|
Id = 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"),
|
|
FK_FromUomId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_ToUomId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Factor = table.Column<decimal>(type: "decimal(65,30)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_UomConversions", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_UomConversions_Items_FK_ItemId",
|
|
column: x => x.FK_ItemId,
|
|
principalTable: "Items",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_UomConversions_Uoms_FK_FromUomId",
|
|
column: x => x.FK_FromUomId,
|
|
principalTable: "Uoms",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_UomConversions_Uoms_FK_ToUomId",
|
|
column: x => x.FK_ToUomId,
|
|
principalTable: "Uoms",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Orders",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
OrderDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
FK_StoreId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
TotalAmount = 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_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: "StoreKycDocuments",
|
|
columns: table => new
|
|
{
|
|
Id = 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"),
|
|
DocumentType = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
FileReference = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
UploadedAt = 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_StoreKycDocuments", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_StoreKycDocuments_Stores_FK_StoreId",
|
|
column: x => x.FK_StoreId,
|
|
principalTable: "Stores",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "UserStoreScopes",
|
|
columns: table => new
|
|
{
|
|
FK_UserId = 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"),
|
|
Id = 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_UserStoreScopes", x => new { x.FK_UserId, x.FK_StoreId });
|
|
table.ForeignKey(
|
|
name: "FK_UserStoreScopes_Stores_FK_StoreId",
|
|
column: x => x.FK_StoreId,
|
|
principalTable: "Stores",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_UserStoreScopes_Users_FK_UserId",
|
|
column: x => x.FK_UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SchemeBundleComponents",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_SchemeId = 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"),
|
|
Qty = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SchemeBundleComponents", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_SchemeBundleComponents_Items_FK_ItemId",
|
|
column: x => x.FK_ItemId,
|
|
principalTable: "Items",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_SchemeBundleComponents_Schemes_FK_SchemeId",
|
|
column: x => x.FK_SchemeId,
|
|
principalTable: "Schemes",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "OrderItems",
|
|
columns: table => new
|
|
{
|
|
FK_OrderId = 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"),
|
|
Quantity = table.Column<int>(type: "int", nullable: false),
|
|
UnitPrice = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
Id = 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_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.CreateTable(
|
|
name: "SchemeRedemptions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_SchemeId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_OrderId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
FieldInvoiceId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
DiscountAmount = table.Column<decimal>(type: "decimal(65,30)", nullable: true),
|
|
FK_FreeItemId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
FreeQty = table.Column<decimal>(type: "decimal(65,30)", nullable: true),
|
|
FreeItemCostValue = table.Column<decimal>(type: "decimal(65,30)", nullable: true),
|
|
RedeemedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SchemeRedemptions", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_SchemeRedemptions_Items_FK_FreeItemId",
|
|
column: x => x.FK_FreeItemId,
|
|
principalTable: "Items",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_SchemeRedemptions_Orders_FK_OrderId",
|
|
column: x => x.FK_OrderId,
|
|
principalTable: "Orders",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_SchemeRedemptions_Schemes_FK_SchemeId",
|
|
column: x => x.FK_SchemeId,
|
|
principalTable: "Schemes",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "DeliveryRuns",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
RideType = table.Column<int>(type: "int", nullable: false),
|
|
Status = table.Column<int>(type: "int", nullable: false),
|
|
FK_VehicleId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_DriverProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_RouteId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_SourceWarehouseId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Meterstart = table.Column<int>(type: "int", nullable: false),
|
|
Meterend = table.Column<int>(type: "int", nullable: false),
|
|
StartedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
ActivatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
ClosedAt = 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_DeliveryRuns", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_DeliveryRuns_DriverProfiles_FK_DriverProfileId",
|
|
column: x => x.FK_DriverProfileId,
|
|
principalTable: "DriverProfiles",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_DeliveryRuns_Routes_FK_RouteId",
|
|
column: x => x.FK_RouteId,
|
|
principalTable: "Routes",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "RideCancelRequests",
|
|
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"),
|
|
TypeCode = table.Column<int>(type: "int", nullable: false),
|
|
Reason = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
RequestedBy = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
RequestedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
Status = table.Column<int>(type: "int", nullable: false),
|
|
ApprovedBy = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
ApprovedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_RideCancelRequests", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_RideCancelRequests_DeliveryRuns_FK_RideId",
|
|
column: x => x.FK_RideId,
|
|
principalTable: "DeliveryRuns",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "LoadingSheetItems",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FK_LoadingSheetId = 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"),
|
|
QuantityDispatched = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
QuantityReceived = table.Column<decimal>(type: "decimal(65,30)", nullable: true),
|
|
QuantityResolved = table.Column<decimal>(type: "decimal(65,30)", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_LoadingSheetItems", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_LoadingSheetItems_Items_FK_ItemId",
|
|
column: x => x.FK_ItemId,
|
|
principalTable: "Items",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "LoadingSheets",
|
|
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_SourceWarehouseId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Status = table.Column<int>(type: "int", nullable: false),
|
|
DispatchConfirmedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
DispatchConfirmedBy = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
ReceiptConfirmedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
ReceiptConfirmedBy = table.Column<Guid>(type: "char(36)", nullable: true, 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_LoadingSheets", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_LoadingSheets_DeliveryRuns_FK_RideId",
|
|
column: x => x.FK_RideId,
|
|
principalTable: "DeliveryRuns",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Vehicles",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
RegNumber = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
NumberPlate = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Type = table.Column<int>(type: "int", nullable: false),
|
|
DefaultWarehouseId = table.Column<Guid>(type: "char(36)", nullable: true, 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_Vehicles", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Warehouses",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Location = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Type = table.Column<int>(type: "int", nullable: false),
|
|
VehicleId = table.Column<Guid>(type: "char(36)", nullable: true, 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_Warehouses", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Warehouses_Vehicles_VehicleId",
|
|
column: x => x.VehicleId,
|
|
principalTable: "Vehicles",
|
|
principalColumn: "Id");
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.InsertData(
|
|
table: "Roles",
|
|
columns: new[] { "Id", "CreatedAt", "IsActive", "Level", "Name" },
|
|
values: new object[,]
|
|
{
|
|
{ new Guid("10000000-0000-0000-0000-000000000001"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), true, 10, "SalesRep" },
|
|
{ new Guid("10000000-0000-0000-0000-000000000002"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), true, 20, "Supervisor" },
|
|
{ new Guid("10000000-0000-0000-0000-000000000003"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), true, 30, "AreaManager" },
|
|
{ new Guid("10000000-0000-0000-0000-000000000004"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), true, 40, "AreaSupervisor" },
|
|
{ new Guid("10000000-0000-0000-0000-000000000005"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), true, 50, "RegionalManager" },
|
|
{ new Guid("10000000-0000-0000-0000-000000000006"), new DateTime(2026, 8, 18, 0, 0, 0, 0, DateTimeKind.Unspecified), true, 60, "RegionalAgency" }
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeliveryRuns_FK_DriverProfileId",
|
|
table: "DeliveryRuns",
|
|
column: "FK_DriverProfileId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeliveryRuns_FK_RouteId",
|
|
table: "DeliveryRuns",
|
|
column: "FK_RouteId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeliveryRuns_FK_SourceWarehouseId",
|
|
table: "DeliveryRuns",
|
|
column: "FK_SourceWarehouseId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DeliveryRuns_FK_VehicleId",
|
|
table: "DeliveryRuns",
|
|
column: "FK_VehicleId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DriverProfiles_FK_UserId",
|
|
table: "DriverProfiles",
|
|
column: "FK_UserId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Items_FK_BaseUomId",
|
|
table: "Items",
|
|
column: "FK_BaseUomId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Items_FK_BrandId",
|
|
table: "Items",
|
|
column: "FK_BrandId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Items_FK_CategoryId",
|
|
table: "Items",
|
|
column: "FK_CategoryId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Items_FK_SubCategoryId",
|
|
table: "Items",
|
|
column: "FK_SubCategoryId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LoadingSheetItems_FK_ItemId",
|
|
table: "LoadingSheetItems",
|
|
column: "FK_ItemId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LoadingSheetItems_FK_LoadingSheetId",
|
|
table: "LoadingSheetItems",
|
|
column: "FK_LoadingSheetId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LoadingSheets_FK_RideId",
|
|
table: "LoadingSheets",
|
|
column: "FK_RideId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LoadingSheets_FK_SourceWarehouseId",
|
|
table: "LoadingSheets",
|
|
column: "FK_SourceWarehouseId");
|
|
|
|
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_PriceListItems_FK_ItemId",
|
|
table: "PriceListItems",
|
|
column: "FK_ItemId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PriceListItems_FK_PriceListId_FK_ItemId",
|
|
table: "PriceListItems",
|
|
columns: new[] { "FK_PriceListId", "FK_ItemId" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PriceLists_FK_RegionId",
|
|
table: "PriceLists",
|
|
column: "FK_RegionId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_RideCancelRequests_FK_RideId",
|
|
table: "RideCancelRequests",
|
|
column: "FK_RideId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_RolePermissions_FK_PermissionId",
|
|
table: "RolePermissions",
|
|
column: "FK_PermissionId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Routes_FK_RegionId",
|
|
table: "Routes",
|
|
column: "FK_RegionId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SchemeBundleComponents_FK_ItemId",
|
|
table: "SchemeBundleComponents",
|
|
column: "FK_ItemId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SchemeBundleComponents_FK_SchemeId_FK_ItemId",
|
|
table: "SchemeBundleComponents",
|
|
columns: new[] { "FK_SchemeId", "FK_ItemId" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SchemeRedemptions_FK_FreeItemId",
|
|
table: "SchemeRedemptions",
|
|
column: "FK_FreeItemId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SchemeRedemptions_FK_OrderId",
|
|
table: "SchemeRedemptions",
|
|
column: "FK_OrderId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SchemeRedemptions_FK_SchemeId",
|
|
table: "SchemeRedemptions",
|
|
column: "FK_SchemeId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Schemes_FK_FreeItemId",
|
|
table: "Schemes",
|
|
column: "FK_FreeItemId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Schemes_FK_TriggerItemId",
|
|
table: "Schemes",
|
|
column: "FK_TriggerItemId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Schemes_RegionId",
|
|
table: "Schemes",
|
|
column: "RegionId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_StockBalances_FK_ItemId_LocationId",
|
|
table: "StockBalances",
|
|
columns: new[] { "FK_ItemId", "LocationId" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_StockMovements_FK_ItemId",
|
|
table: "StockMovements",
|
|
column: "FK_ItemId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_StoreKycDocuments_FK_StoreId",
|
|
table: "StoreKycDocuments",
|
|
column: "FK_StoreId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Stores_FK_RouteId",
|
|
table: "Stores",
|
|
column: "FK_RouteId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SubCategories_FK_CategoryId",
|
|
table: "SubCategories",
|
|
column: "FK_CategoryId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_UomConversions_FK_FromUomId",
|
|
table: "UomConversions",
|
|
column: "FK_FromUomId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_UomConversions_FK_ItemId",
|
|
table: "UomConversions",
|
|
column: "FK_ItemId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_UomConversions_FK_ToUomId",
|
|
table: "UomConversions",
|
|
column: "FK_ToUomId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_UserRegionScopes_FK_RegionId",
|
|
table: "UserRegionScopes",
|
|
column: "FK_RegionId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_UserRouteScopes_FK_RouteId",
|
|
table: "UserRouteScopes",
|
|
column: "FK_RouteId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Users_FK_ReportsToUserId",
|
|
table: "Users",
|
|
column: "FK_ReportsToUserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Users_FK_RoleId",
|
|
table: "Users",
|
|
column: "FK_RoleId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_UserStoreScopes_FK_StoreId",
|
|
table: "UserStoreScopes",
|
|
column: "FK_StoreId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Vehicles_DefaultWarehouseId",
|
|
table: "Vehicles",
|
|
column: "DefaultWarehouseId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Warehouses_VehicleId",
|
|
table: "Warehouses",
|
|
column: "VehicleId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_DeliveryRuns_Vehicles_FK_VehicleId",
|
|
table: "DeliveryRuns",
|
|
column: "FK_VehicleId",
|
|
principalTable: "Vehicles",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_DeliveryRuns_Warehouses_FK_SourceWarehouseId",
|
|
table: "DeliveryRuns",
|
|
column: "FK_SourceWarehouseId",
|
|
principalTable: "Warehouses",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_LoadingSheetItems_LoadingSheets_FK_LoadingSheetId",
|
|
table: "LoadingSheetItems",
|
|
column: "FK_LoadingSheetId",
|
|
principalTable: "LoadingSheets",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_LoadingSheets_Warehouses_FK_SourceWarehouseId",
|
|
table: "LoadingSheets",
|
|
column: "FK_SourceWarehouseId",
|
|
principalTable: "Warehouses",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_Vehicles_Warehouses_DefaultWarehouseId",
|
|
table: "Vehicles",
|
|
column: "DefaultWarehouseId",
|
|
principalTable: "Warehouses",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_Warehouses_Vehicles_VehicleId",
|
|
table: "Warehouses");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "DriverComplianceConfigs");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "LoadingSheetItems");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "OrderItems");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PriceListItems");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "RideCancelRequests");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "RolePermissions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SaleRoutes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SchemeBundleComponents");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SchemeRedemptions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "StockBalances");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "StockMovements");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "StoreKycDocuments");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Suppliers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "UomConversions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "UserRegionScopes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "UserRouteScopes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "UserStoreScopes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "LoadingSheets");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PriceLists");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Permissions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Orders");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Schemes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "DeliveryRuns");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Stores");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Items");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "DriverProfiles");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Routes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Brands");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SubCategories");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Uoms");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Users");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Regions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Categories");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Roles");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Vehicles");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Warehouses");
|
|
}
|
|
}
|
|
}
|