using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace Distribution.Migrations
{
///
public partial class init : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Brands",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Name = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ExternalErpId = table.Column(type: "int", nullable: true),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Name = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ExternalErpId = table.Column(type: "int", nullable: true),
AllowCustomerReturn = table.Column(type: "tinyint(1)", nullable: false),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
EnforceLicenseExpiry = table.Column(type: "tinyint(1)", nullable: false),
EnforceMedicalClearance = table.Column(type: "tinyint(1)", nullable: false),
UpdatedAt = table.Column(type: "datetime(6)", nullable: false),
UpdatedBy = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Code = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Description = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Name = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Name = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Level = table.Column(type: "int", nullable: false),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Name = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ContactInfo = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
PerformanceScore = table.Column(type: "decimal(65,30)", nullable: true),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Name = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ExternalErpId = table.Column(type: "int", nullable: true),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Name = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
FK_CategoryId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ExternalErpId = table.Column(type: "int", nullable: true),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Name = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
FK_RegionId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
EffectiveFrom = table.Column(type: "datetime(6)", nullable: false),
EffectiveTo = table.Column(type: "datetime(6)", nullable: false),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
RouteName = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
StartPoint = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
EndPoint = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Length = table.Column(type: "decimal(65,30)", nullable: false),
FK_RegionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_PermissionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Username = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
PasswordHash = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
FullName = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
FK_RoleId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_ReportsToUserId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
UpdatedAt = table.Column(type: "datetime(6)", nullable: true),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Sku = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Description = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
FK_CategoryId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_SubCategoryId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
FK_BrandId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
FK_BaseUomId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
SalePrice = table.Column(type: "decimal(65,30)", nullable: true),
CostPrice = table.Column(type: "decimal(65,30)", nullable: true),
SyncSource = table.Column(type: "int", nullable: false),
ExternalErpItemId = table.Column(type: "int", nullable: true),
LastSyncedAt = table.Column(type: "datetime(6)", nullable: true),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
OwnerName = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
StoreName = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
StoreAddress = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Latitude = table.Column(type: "decimal(65,30)", nullable: false),
Longitude = table.Column(type: "decimal(65,30)", nullable: false),
OneTimeAmount = table.Column(type: "decimal(65,30)", nullable: false),
CreditAmount = table.Column(type: "decimal(65,30)", nullable: false),
CreditLimit = table.Column(type: "decimal(65,30)", nullable: false),
OutstandingBalance = table.Column(type: "decimal(65,30)", nullable: false),
Segment = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
KycStatus = table.Column(type: "int", nullable: false),
FK_RouteId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
LicenseNumber = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
LicenseExpiry = table.Column(type: "datetime(6)", nullable: false),
MedicalClearanceExpiry = table.Column(type: "datetime(6)", nullable: false),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_RegionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_RouteId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_PriceListId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_ItemId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Price = table.Column(type: "decimal(65,30)", nullable: false),
MinPrice = table.Column(type: "decimal(65,30)", nullable: true),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Name = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
RuleType = table.Column(type: "int", nullable: false),
RuleConfig = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
FK_TriggerItemId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
TriggerQty = table.Column(type: "int", nullable: true),
FK_FreeItemId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
FreeQty = table.Column(type: "decimal(65,30)", nullable: true),
FK_RegionId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
RegionId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
EligibleSegment = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
DateRangeFrom = table.Column(type: "datetime(6)", nullable: false),
DateRangeTo = table.Column(type: "datetime(6)", nullable: false),
AgentLimitExempt = table.Column(type: "tinyint(1)", nullable: false),
BaselineExpectedSales = table.Column(type: "decimal(65,30)", nullable: true),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_ItemId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
LocationId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
LocationType = table.Column(type: "int", nullable: false),
Quantity = table.Column(type: "decimal(65,30)", nullable: false),
UpdatedAt = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_ItemId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FromLocationId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
FromLocationType = table.Column(type: "int", nullable: true),
ToLocationId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
ToLocationType = table.Column(type: "int", nullable: true),
Quantity = table.Column(type: "decimal(65,30)", nullable: false),
Type = table.Column(type: "int", nullable: false),
ReasonCode = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ReferenceId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
CreatedBy = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_ItemId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_FromUomId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_ToUomId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Factor = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
OrderDate = table.Column(type: "datetime(6)", nullable: false),
FK_StoreId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
TotalAmount = table.Column(type: "decimal(65,30)", nullable: false),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_StoreId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
DocumentType = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
FileReference = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
UploadedAt = table.Column(type: "datetime(6)", nullable: false),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_StoreId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_SchemeId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_ItemId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Qty = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_ItemId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Quantity = table.Column(type: "int", nullable: false),
UnitPrice = table.Column(type: "decimal(65,30)", nullable: false),
Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_SchemeId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_OrderId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
FieldInvoiceId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
DiscountAmount = table.Column(type: "decimal(65,30)", nullable: true),
FK_FreeItemId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
FreeQty = table.Column(type: "decimal(65,30)", nullable: true),
FreeItemCostValue = table.Column(type: "decimal(65,30)", nullable: true),
RedeemedAt = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
RideType = table.Column(type: "int", nullable: false),
Status = table.Column(type: "int", nullable: false),
FK_VehicleId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_DriverProfileId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_RouteId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_SourceWarehouseId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Meterstart = table.Column(type: "int", nullable: false),
Meterend = table.Column(type: "int", nullable: false),
StartedAt = table.Column(type: "datetime(6)", nullable: true),
ActivatedAt = table.Column(type: "datetime(6)", nullable: true),
ClosedAt = table.Column(type: "datetime(6)", nullable: true),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_RideId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
TypeCode = table.Column(type: "int", nullable: false),
Reason = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
RequestedBy = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
RequestedAt = table.Column(type: "datetime(6)", nullable: false),
Status = table.Column(type: "int", nullable: false),
ApprovedBy = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
ApprovedAt = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_LoadingSheetId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_ItemId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
QuantityDispatched = table.Column(type: "decimal(65,30)", nullable: false),
QuantityReceived = table.Column(type: "decimal(65,30)", nullable: true),
QuantityResolved = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_RideId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
FK_SourceWarehouseId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Status = table.Column(type: "int", nullable: false),
DispatchConfirmedAt = table.Column(type: "datetime(6)", nullable: true),
DispatchConfirmedBy = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
ReceiptConfirmedAt = table.Column(type: "datetime(6)", nullable: true),
ReceiptConfirmedBy = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
IsActive = table.Column(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(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
RegNumber = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
NumberPlate = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Type = table.Column(type: "int", nullable: false),
DefaultWarehouseId = table.Column