using System; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace PSTW_CentralSystem.Migrations.InventoryDB { /// public partial class Initiate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "CompanyModel", columns: table => new { CompanyId = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), CompanyName = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_CompanyModel", x => x.CompanyId); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Manufacturers", columns: table => new { ManufacturerId = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), ManufacturerName = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_Manufacturers", x => x.ManufacturerId); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Suppliers", columns: table => new { SupplierId = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), SupplierName = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), SupplierGender = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), SupplierEmail = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), SupplierPhoneNo = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_Suppliers", x => x.SupplierId); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "DepartmentModel", columns: table => new { DepartmentId = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), DepartmentName = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), DepartmentCode = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), CompanyId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_DepartmentModel", x => x.DepartmentId); table.ForeignKey( name: "FK_DepartmentModel_CompanyModel_CompanyId", column: x => x.CompanyId, principalTable: "CompanyModel", principalColumn: "CompanyId", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Products", columns: table => new { ProductId = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), ProductName = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), ManufacturerId = table.Column(type: "int", nullable: false), Category = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), ModelNo = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), QuantityProduct = table.Column(type: "int", nullable: true), ImageProduct = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_Products", x => x.ProductId); table.ForeignKey( name: "FK_Products_Manufacturers_ManufacturerId", column: x => x.ManufacturerId, principalTable: "Manufacturers", principalColumn: "ManufacturerId", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "UserModel", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), FullName = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), UserStatus = table.Column(type: "int", nullable: true), departmentId = table.Column(type: "int", nullable: true), UserName = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), NormalizedUserName = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Email = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), NormalizedEmail = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), EmailConfirmed = table.Column(type: "tinyint(1)", nullable: false), PasswordHash = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), SecurityStamp = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), ConcurrencyStamp = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), PhoneNumber = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), PhoneNumberConfirmed = table.Column(type: "tinyint(1)", nullable: false), TwoFactorEnabled = table.Column(type: "tinyint(1)", nullable: false), LockoutEnd = table.Column(type: "datetime(6)", nullable: true), LockoutEnabled = table.Column(type: "tinyint(1)", nullable: false), AccessFailedCount = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_UserModel", x => x.Id); table.ForeignKey( name: "FK_UserModel_DepartmentModel_departmentId", column: x => x.departmentId, principalTable: "DepartmentModel", principalColumn: "DepartmentId"); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Items", columns: table => new { ItemID = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), UniqueID = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), CompanyId = table.Column(type: "int", nullable: false), DepartmentId = table.Column(type: "int", nullable: false), ProductId = table.Column(type: "int", nullable: false), SerialNumber = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), TeamType = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Quantity = table.Column(type: "int", nullable: false), Supplier = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), PurchaseDate = table.Column(type: "datetime(6)", nullable: false), PONo = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Currency = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), PriceInRM = table.Column(type: "float", nullable: false), CurrencyRate = table.Column(type: "float", nullable: false), ConvertPrice = table.Column(type: "float", nullable: false), DONo = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), DODate = table.Column(type: "datetime(6)", nullable: true), Warranty = table.Column(type: "int", nullable: false), EndWDate = table.Column(type: "datetime(6)", nullable: false), InvoiceNo = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), InvoiceDate = table.Column(type: "datetime(6)", nullable: true), ItemStatus = table.Column(type: "int", nullable: false, comment: "1 = In stock; 2 = Item Moving; 3 = Item Out; 4 = Item Broken; 5 = Item Lost; 6 = Item Stolen; 7 = Item Damaged; 8 = Item Discarded; 9 = Item Destroyed; 10 = Item Finished;"), ItemLocation = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), CreatedByUserId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Items", x => x.ItemID); table.ForeignKey( name: "FK_Items_CompanyModel_CompanyId", column: x => x.CompanyId, principalTable: "CompanyModel", principalColumn: "CompanyId", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Items_DepartmentModel_DepartmentId", column: x => x.DepartmentId, principalTable: "DepartmentModel", principalColumn: "DepartmentId", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Items_Products_ProductId", column: x => x.ProductId, principalTable: "Products", principalColumn: "ProductId", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Items_UserModel_CreatedByUserId", column: x => x.CreatedByUserId, principalTable: "UserModel", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_DepartmentModel_CompanyId", table: "DepartmentModel", column: "CompanyId"); migrationBuilder.CreateIndex( name: "IX_Items_CompanyId", table: "Items", column: "CompanyId"); migrationBuilder.CreateIndex( name: "IX_Items_CreatedByUserId", table: "Items", column: "CreatedByUserId"); migrationBuilder.CreateIndex( name: "IX_Items_DepartmentId", table: "Items", column: "DepartmentId"); migrationBuilder.CreateIndex( name: "IX_Items_ProductId", table: "Items", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_Products_ManufacturerId", table: "Products", column: "ManufacturerId"); migrationBuilder.CreateIndex( name: "IX_UserModel_departmentId", table: "UserModel", column: "departmentId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Items"); migrationBuilder.DropTable( name: "Suppliers"); migrationBuilder.DropTable( name: "Products"); migrationBuilder.DropTable( name: "UserModel"); migrationBuilder.DropTable( name: "Manufacturers"); migrationBuilder.DropTable( name: "DepartmentModel"); migrationBuilder.DropTable( name: "CompanyModel"); } } }