marco.pms.api/Marco.Pms.DataAccess/Migrations/20251027073344_Added_Inventory_Related_Tables.cs

1185 lines
59 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Marco.Pms.DataAccess.Migrations
{
/// <inheritdoc />
public partial class Added_Inventory_Related_Tables : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ItemCategoryMasters",
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"),
Description = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_ItemCategoryMasters", x => x.Id);
table.ForeignKey(
name: "FK_ItemCategoryMasters_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Manufacturers",
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")
},
constraints: table =>
{
table.PrimaryKey("PK_Manufacturers", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "PurchaseOrderStatus",
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"),
Description = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_PurchaseOrderStatus", x => x.Id);
table.ForeignKey(
name: "FK_PurchaseOrderStatus_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "RequisitionStatus",
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"),
Description = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_RequisitionStatus", x => x.Id);
table.ForeignKey(
name: "FK_RequisitionStatus_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ServicesTaxTypes",
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"),
Description = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_ServicesTaxTypes", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "StateMasters",
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"),
StateCode = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_StateMasters", 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"),
Email = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
SupplierGroup = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
BankName = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
AccountNumber = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
IFSC = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
SupplierUId = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
CreatedById = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
UpdatedById = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_Suppliers", x => x.Id);
table.ForeignKey(
name: "FK_Suppliers_Employees_CreatedById",
column: x => x.CreatedById,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Suppliers_Employees_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Employees",
principalColumn: "Id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "TaxSlabMasters",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Percentage = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TaxSlabMasters", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "UnitTypes",
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"),
Description = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_UnitTypes", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ItemGroupMasters",
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"),
Description = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
ItemCategoryId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_ItemGroupMasters", x => x.Id);
table.ForeignKey(
name: "FK_ItemGroupMasters_ItemCategoryMasters_ItemCategoryId",
column: x => x.ItemCategoryId,
principalTable: "ItemCategoryMasters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "PurchaseOrderStatusLogs",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
PreviousPurchaseStatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Comment = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
PurchaseStatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
UpdatedById = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_PurchaseOrderStatusLogs", x => x.Id);
table.ForeignKey(
name: "FK_PurchaseOrderStatusLogs_Employees_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PurchaseOrderStatusLogs_PurchaseOrderStatus_PreviousPurchase~",
column: x => x.PreviousPurchaseStatusId,
principalTable: "PurchaseOrderStatus",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PurchaseOrderStatusLogs_PurchaseOrderStatus_PurchaseStatusId",
column: x => x.PurchaseStatusId,
principalTable: "PurchaseOrderStatus",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PurchaseOrderStatusLogs_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "PurchaseStatusEmployeeMappings",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
PurchaseOrderStatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
EmployeeId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_PurchaseStatusEmployeeMappings", x => x.Id);
table.ForeignKey(
name: "FK_PurchaseStatusEmployeeMappings_Employees_EmployeeId",
column: x => x.EmployeeId,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PurchaseStatusEmployeeMappings_PurchaseOrderStatus_PurchaseO~",
column: x => x.PurchaseOrderStatusId,
principalTable: "PurchaseOrderStatus",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PurchaseStatusEmployeeMappings_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "PurchaseStatusMappings",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
PreviousPurchaseStatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
PurchaseStatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
NextPurchaseStatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_PurchaseStatusMappings", x => x.Id);
table.ForeignKey(
name: "FK_PurchaseStatusMappings_PurchaseOrderStatus_NextPurchaseStatu~",
column: x => x.NextPurchaseStatusId,
principalTable: "PurchaseOrderStatus",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PurchaseStatusMappings_PurchaseOrderStatus_PreviousPurchaseS~",
column: x => x.PreviousPurchaseStatusId,
principalTable: "PurchaseOrderStatus",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PurchaseStatusMappings_PurchaseOrderStatus_PurchaseStatusId",
column: x => x.PurchaseStatusId,
principalTable: "PurchaseOrderStatus",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PurchaseStatusMappings_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "RequisitionStatusEmployeeMappings",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
RequisitionStatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
EmployeeId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_RequisitionStatusEmployeeMappings", x => x.Id);
table.ForeignKey(
name: "FK_RequisitionStatusEmployeeMappings_Employees_EmployeeId",
column: x => x.EmployeeId,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RequisitionStatusEmployeeMappings_RequisitionStatus_Requisit~",
column: x => x.RequisitionStatusId,
principalTable: "RequisitionStatus",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RequisitionStatusEmployeeMappings_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "RequisitionStatusLogs",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
PreviousRequisitionStatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Comment = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
RequisitionStatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
UpdatedById = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_RequisitionStatusLogs", x => x.Id);
table.ForeignKey(
name: "FK_RequisitionStatusLogs_Employees_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RequisitionStatusLogs_PurchaseOrderStatus_PreviousRequisitio~",
column: x => x.PreviousRequisitionStatusId,
principalTable: "PurchaseOrderStatus",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RequisitionStatusLogs_RequisitionStatus_RequisitionStatusId",
column: x => x.RequisitionStatusId,
principalTable: "RequisitionStatus",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RequisitionStatusLogs_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "RequisitionStatusMappings",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
PreviousRequisitionStatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
RequisitionStatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
NextRequisitionStatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_RequisitionStatusMappings", x => x.Id);
table.ForeignKey(
name: "FK_RequisitionStatusMappings_RequisitionStatus_NextRequisitionS~",
column: x => x.NextRequisitionStatusId,
principalTable: "RequisitionStatus",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RequisitionStatusMappings_RequisitionStatus_PreviousRequisit~",
column: x => x.PreviousRequisitionStatusId,
principalTable: "RequisitionStatus",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RequisitionStatusMappings_RequisitionStatus_RequisitionStatu~",
column: x => x.RequisitionStatusId,
principalTable: "RequisitionStatus",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RequisitionStatusMappings_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "SupplierStateMappings",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
StateId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Street = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CityName = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
PinCode = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Country = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
GSTNumber = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ContactPerson = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ContactEmail = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ContactPhone = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
SupplierId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_SupplierStateMappings", x => x.Id);
table.ForeignKey(
name: "FK_SupplierStateMappings_StateMasters_StateId",
column: x => x.StateId,
principalTable: "StateMasters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_SupplierStateMappings_Suppliers_SupplierId",
column: x => x.SupplierId,
principalTable: "Suppliers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "TechnicalUnits",
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"),
Description = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
UnitTypeId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_TechnicalUnits", x => x.Id);
table.ForeignKey(
name: "FK_TechnicalUnits_UnitTypes_UnitTypeId",
column: x => x.UnitTypeId,
principalTable: "UnitTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Items",
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"),
Description = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ItemGroupId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
TechnicalUnitId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ItemUId = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Threshold = table.Column<int>(type: "int", nullable: false),
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
CreatedById = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
UpdatedById = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_Items", x => x.Id);
table.ForeignKey(
name: "FK_Items_Employees_CreatedById",
column: x => x.CreatedById,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Items_Employees_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Employees",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Items_ItemGroupMasters_ItemGroupId",
column: x => x.ItemGroupId,
principalTable: "ItemGroupMasters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Items_TechnicalUnits_TechnicalUnitId",
column: x => x.TechnicalUnitId,
principalTable: "TechnicalUnits",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Items_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ItemManufacturerMappings",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ItemId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ManufacturerId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_ItemManufacturerMappings", x => x.Id);
table.ForeignKey(
name: "FK_ItemManufacturerMappings_Items_ItemId",
column: x => x.ItemId,
principalTable: "Items",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ItemManufacturerMappings_Manufacturers_ManufacturerId",
column: x => x.ManufacturerId,
principalTable: "Manufacturers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ItemManufacturerMappings_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ItemTaxTypeMappings",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ItemId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ServicesTaxTypeId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Rate = table.Column<int>(type: "int", nullable: false),
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_ItemTaxTypeMappings", x => x.Id);
table.ForeignKey(
name: "FK_ItemTaxTypeMappings_Items_ItemId",
column: x => x.ItemId,
principalTable: "Items",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ItemTaxTypeMappings_ServicesTaxTypes_ServicesTaxTypeId",
column: x => x.ServicesTaxTypeId,
principalTable: "ServicesTaxTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ItemTaxTypeMappings_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Requisitions",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ItemId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ProjectId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
BatchId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
NumberOfItems = table.Column<int>(type: "int", nullable: false),
RequisitionStatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
RequisitionUId = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
CreatedById = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
UpdatedById = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_Requisitions", x => x.Id);
table.ForeignKey(
name: "FK_Requisitions_Employees_CreatedById",
column: x => x.CreatedById,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Requisitions_Employees_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Employees",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Requisitions_Items_ItemId",
column: x => x.ItemId,
principalTable: "Items",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Requisitions_Projects_ProjectId",
column: x => x.ProjectId,
principalTable: "Projects",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Requisitions_RequisitionStatus_RequisitionStatusId",
column: x => x.RequisitionStatusId,
principalTable: "RequisitionStatus",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Requisitions_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ItemSupplierMappings",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ItemManufacturerMappingId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
SupplierId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
BasePrice = table.Column<double>(type: "double", nullable: false),
PurchaseLeadTime = table.Column<int>(type: "int", nullable: false),
CurrencyId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_ItemSupplierMappings", x => x.Id);
table.ForeignKey(
name: "FK_ItemSupplierMappings_CurrencyMaster_CurrencyId",
column: x => x.CurrencyId,
principalTable: "CurrencyMaster",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ItemSupplierMappings_ItemManufacturerMappings_ItemManufactur~",
column: x => x.ItemManufacturerMappingId,
principalTable: "ItemManufacturerMappings",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ItemSupplierMappings_Suppliers_SupplierId",
column: x => x.SupplierId,
principalTable: "Suppliers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ItemSupplierMappings_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "PurchaseOrders",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ItemSupplierMappingId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ProjectId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
RequisitionBatchId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
NumberOfItems = table.Column<int>(type: "int", nullable: false),
PricePerItem = table.Column<double>(type: "double", nullable: false),
TotalBasePrice = table.Column<double>(type: "double", nullable: false),
TotalTaxPrice = table.Column<double>(type: "double", nullable: false),
TotalDiscountPrice = table.Column<double>(type: "double", nullable: false),
TotalPrice = table.Column<double>(type: "double", nullable: false),
PurchaseOrderStatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
BatchId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
PurchaseOrderUId = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
CreatedById = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
UpdatedById = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_PurchaseOrders", x => x.Id);
table.ForeignKey(
name: "FK_PurchaseOrders_Employees_CreatedById",
column: x => x.CreatedById,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PurchaseOrders_Employees_UpdatedById",
column: x => x.UpdatedById,
principalTable: "Employees",
principalColumn: "Id");
table.ForeignKey(
name: "FK_PurchaseOrders_ItemSupplierMappings_ItemSupplierMappingId",
column: x => x.ItemSupplierMappingId,
principalTable: "ItemSupplierMappings",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PurchaseOrders_Projects_ProjectId",
column: x => x.ProjectId,
principalTable: "Projects",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PurchaseOrders_PurchaseOrderStatus_PurchaseOrderStatusId",
column: x => x.PurchaseOrderStatusId,
principalTable: "PurchaseOrderStatus",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_PurchaseOrders_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_ItemCategoryMasters_TenantId",
table: "ItemCategoryMasters",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_ItemGroupMasters_ItemCategoryId",
table: "ItemGroupMasters",
column: "ItemCategoryId");
migrationBuilder.CreateIndex(
name: "IX_ItemManufacturerMappings_ItemId",
table: "ItemManufacturerMappings",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_ItemManufacturerMappings_ManufacturerId",
table: "ItemManufacturerMappings",
column: "ManufacturerId");
migrationBuilder.CreateIndex(
name: "IX_ItemManufacturerMappings_TenantId",
table: "ItemManufacturerMappings",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_Items_CreatedById",
table: "Items",
column: "CreatedById");
migrationBuilder.CreateIndex(
name: "IX_Items_ItemGroupId",
table: "Items",
column: "ItemGroupId");
migrationBuilder.CreateIndex(
name: "IX_Items_TechnicalUnitId",
table: "Items",
column: "TechnicalUnitId");
migrationBuilder.CreateIndex(
name: "IX_Items_TenantId",
table: "Items",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_Items_UpdatedById",
table: "Items",
column: "UpdatedById");
migrationBuilder.CreateIndex(
name: "IX_ItemSupplierMappings_CurrencyId",
table: "ItemSupplierMappings",
column: "CurrencyId");
migrationBuilder.CreateIndex(
name: "IX_ItemSupplierMappings_ItemManufacturerMappingId",
table: "ItemSupplierMappings",
column: "ItemManufacturerMappingId");
migrationBuilder.CreateIndex(
name: "IX_ItemSupplierMappings_SupplierId",
table: "ItemSupplierMappings",
column: "SupplierId");
migrationBuilder.CreateIndex(
name: "IX_ItemSupplierMappings_TenantId",
table: "ItemSupplierMappings",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_ItemTaxTypeMappings_ItemId",
table: "ItemTaxTypeMappings",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_ItemTaxTypeMappings_ServicesTaxTypeId",
table: "ItemTaxTypeMappings",
column: "ServicesTaxTypeId");
migrationBuilder.CreateIndex(
name: "IX_ItemTaxTypeMappings_TenantId",
table: "ItemTaxTypeMappings",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseOrders_CreatedById",
table: "PurchaseOrders",
column: "CreatedById");
migrationBuilder.CreateIndex(
name: "IX_PurchaseOrders_ItemSupplierMappingId",
table: "PurchaseOrders",
column: "ItemSupplierMappingId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseOrders_ProjectId",
table: "PurchaseOrders",
column: "ProjectId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseOrders_PurchaseOrderStatusId",
table: "PurchaseOrders",
column: "PurchaseOrderStatusId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseOrders_TenantId",
table: "PurchaseOrders",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseOrders_UpdatedById",
table: "PurchaseOrders",
column: "UpdatedById");
migrationBuilder.CreateIndex(
name: "IX_PurchaseOrderStatus_TenantId",
table: "PurchaseOrderStatus",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseOrderStatusLogs_PreviousPurchaseStatusId",
table: "PurchaseOrderStatusLogs",
column: "PreviousPurchaseStatusId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseOrderStatusLogs_PurchaseStatusId",
table: "PurchaseOrderStatusLogs",
column: "PurchaseStatusId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseOrderStatusLogs_TenantId",
table: "PurchaseOrderStatusLogs",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseOrderStatusLogs_UpdatedById",
table: "PurchaseOrderStatusLogs",
column: "UpdatedById");
migrationBuilder.CreateIndex(
name: "IX_PurchaseStatusEmployeeMappings_EmployeeId",
table: "PurchaseStatusEmployeeMappings",
column: "EmployeeId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseStatusEmployeeMappings_PurchaseOrderStatusId",
table: "PurchaseStatusEmployeeMappings",
column: "PurchaseOrderStatusId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseStatusEmployeeMappings_TenantId",
table: "PurchaseStatusEmployeeMappings",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseStatusMappings_NextPurchaseStatusId",
table: "PurchaseStatusMappings",
column: "NextPurchaseStatusId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseStatusMappings_PreviousPurchaseStatusId",
table: "PurchaseStatusMappings",
column: "PreviousPurchaseStatusId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseStatusMappings_PurchaseStatusId",
table: "PurchaseStatusMappings",
column: "PurchaseStatusId");
migrationBuilder.CreateIndex(
name: "IX_PurchaseStatusMappings_TenantId",
table: "PurchaseStatusMappings",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_Requisitions_CreatedById",
table: "Requisitions",
column: "CreatedById");
migrationBuilder.CreateIndex(
name: "IX_Requisitions_ItemId",
table: "Requisitions",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_Requisitions_ProjectId",
table: "Requisitions",
column: "ProjectId");
migrationBuilder.CreateIndex(
name: "IX_Requisitions_RequisitionStatusId",
table: "Requisitions",
column: "RequisitionStatusId");
migrationBuilder.CreateIndex(
name: "IX_Requisitions_TenantId",
table: "Requisitions",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_Requisitions_UpdatedById",
table: "Requisitions",
column: "UpdatedById");
migrationBuilder.CreateIndex(
name: "IX_RequisitionStatus_TenantId",
table: "RequisitionStatus",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_RequisitionStatusEmployeeMappings_EmployeeId",
table: "RequisitionStatusEmployeeMappings",
column: "EmployeeId");
migrationBuilder.CreateIndex(
name: "IX_RequisitionStatusEmployeeMappings_RequisitionStatusId",
table: "RequisitionStatusEmployeeMappings",
column: "RequisitionStatusId");
migrationBuilder.CreateIndex(
name: "IX_RequisitionStatusEmployeeMappings_TenantId",
table: "RequisitionStatusEmployeeMappings",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_RequisitionStatusLogs_PreviousRequisitionStatusId",
table: "RequisitionStatusLogs",
column: "PreviousRequisitionStatusId");
migrationBuilder.CreateIndex(
name: "IX_RequisitionStatusLogs_RequisitionStatusId",
table: "RequisitionStatusLogs",
column: "RequisitionStatusId");
migrationBuilder.CreateIndex(
name: "IX_RequisitionStatusLogs_TenantId",
table: "RequisitionStatusLogs",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_RequisitionStatusLogs_UpdatedById",
table: "RequisitionStatusLogs",
column: "UpdatedById");
migrationBuilder.CreateIndex(
name: "IX_RequisitionStatusMappings_NextRequisitionStatusId",
table: "RequisitionStatusMappings",
column: "NextRequisitionStatusId");
migrationBuilder.CreateIndex(
name: "IX_RequisitionStatusMappings_PreviousRequisitionStatusId",
table: "RequisitionStatusMappings",
column: "PreviousRequisitionStatusId");
migrationBuilder.CreateIndex(
name: "IX_RequisitionStatusMappings_RequisitionStatusId",
table: "RequisitionStatusMappings",
column: "RequisitionStatusId");
migrationBuilder.CreateIndex(
name: "IX_RequisitionStatusMappings_TenantId",
table: "RequisitionStatusMappings",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_Suppliers_CreatedById",
table: "Suppliers",
column: "CreatedById");
migrationBuilder.CreateIndex(
name: "IX_Suppliers_UpdatedById",
table: "Suppliers",
column: "UpdatedById");
migrationBuilder.CreateIndex(
name: "IX_SupplierStateMappings_StateId",
table: "SupplierStateMappings",
column: "StateId");
migrationBuilder.CreateIndex(
name: "IX_SupplierStateMappings_SupplierId",
table: "SupplierStateMappings",
column: "SupplierId");
migrationBuilder.CreateIndex(
name: "IX_TechnicalUnits_UnitTypeId",
table: "TechnicalUnits",
column: "UnitTypeId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ItemTaxTypeMappings");
migrationBuilder.DropTable(
name: "PurchaseOrders");
migrationBuilder.DropTable(
name: "PurchaseOrderStatusLogs");
migrationBuilder.DropTable(
name: "PurchaseStatusEmployeeMappings");
migrationBuilder.DropTable(
name: "PurchaseStatusMappings");
migrationBuilder.DropTable(
name: "Requisitions");
migrationBuilder.DropTable(
name: "RequisitionStatusEmployeeMappings");
migrationBuilder.DropTable(
name: "RequisitionStatusLogs");
migrationBuilder.DropTable(
name: "RequisitionStatusMappings");
migrationBuilder.DropTable(
name: "SupplierStateMappings");
migrationBuilder.DropTable(
name: "TaxSlabMasters");
migrationBuilder.DropTable(
name: "ServicesTaxTypes");
migrationBuilder.DropTable(
name: "ItemSupplierMappings");
migrationBuilder.DropTable(
name: "PurchaseOrderStatus");
migrationBuilder.DropTable(
name: "RequisitionStatus");
migrationBuilder.DropTable(
name: "StateMasters");
migrationBuilder.DropTable(
name: "ItemManufacturerMappings");
migrationBuilder.DropTable(
name: "Suppliers");
migrationBuilder.DropTable(
name: "Items");
migrationBuilder.DropTable(
name: "Manufacturers");
migrationBuilder.DropTable(
name: "ItemGroupMasters");
migrationBuilder.DropTable(
name: "TechnicalUnits");
migrationBuilder.DropTable(
name: "ItemCategoryMasters");
migrationBuilder.DropTable(
name: "UnitTypes");
}
}
}