using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional namespace LingAdmin.API.Migrations { /// public partial class AddInventoryAndAudit : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "AuditLogs", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), User = table.Column(type: "nvarchar(max)", nullable: false), Action = table.Column(type: "nvarchar(max)", nullable: false), Timestamp = table.Column(type: "datetime2", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AuditLogs", x => x.Id); }); migrationBuilder.CreateTable( name: "InventoryItems", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Sku = table.Column(type: "nvarchar(max)", nullable: false), Name = table.Column(type: "nvarchar(max)", nullable: false), Stock = table.Column(type: "int", nullable: false), Price = table.Column(type: "decimal(18,2)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_InventoryItems", x => x.Id); }); migrationBuilder.InsertData( table: "AuditLogs", columns: new[] { "Id", "Action", "Timestamp", "User" }, values: new object[,] { { 101, "Login", new DateTime(2023, 10, 26, 10, 0, 0, 0, DateTimeKind.Unspecified), "Admin" }, { 102, "View Report", new DateTime(2023, 10, 26, 10, 5, 0, 0, DateTimeKind.Unspecified), "User1" }, { 103, "Update Settings", new DateTime(2023, 10, 26, 11, 20, 0, 0, DateTimeKind.Unspecified), "Admin" } }); migrationBuilder.InsertData( table: "InventoryItems", columns: new[] { "Id", "Name", "Price", "Sku", "Stock" }, values: new object[,] { { 1, "Laptop", 1200m, "SKU001", 50 }, { 2, "Mouse", 25m, "SKU002", 200 }, { 3, "Keyboard", 45m, "SKU003", 150 }, { 4, "Monitor", 300m, "SKU004", 80 } }); migrationBuilder.UpdateData( table: "MenuItems", keyColumn: "Id", keyValue: 2, columns: new[] { "Name", "Path" }, values: new object[] { "common.inventory", "/view/inventory" }); migrationBuilder.UpdateData( table: "MenuItems", keyColumn: "Id", keyValue: 3, columns: new[] { "Icon", "Name", "Path" }, values: new object[] { "Settings", "common.audit", "/view/audit" }); migrationBuilder.UpdateData( table: "MenuItems", keyColumn: "Id", keyValue: 4, columns: new[] { "Icon", "Name", "Path" }, values: new object[] { "FileText", "common.requisitions", "/requisitions" }); migrationBuilder.InsertData( table: "MenuItems", columns: new[] { "Id", "Icon", "Name", "Order", "Path" }, values: new object[] { 5, "Users", "common.users", 5, "/users" }); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AuditLogs"); migrationBuilder.DropTable( name: "InventoryItems"); migrationBuilder.DeleteData( table: "MenuItems", keyColumn: "Id", keyValue: 5); migrationBuilder.UpdateData( table: "MenuItems", keyColumn: "Id", keyValue: 2, columns: new[] { "Name", "Path" }, values: new object[] { "common.requisitions", "/requisitions" }); migrationBuilder.UpdateData( table: "MenuItems", keyColumn: "Id", keyValue: 3, columns: new[] { "Icon", "Name", "Path" }, values: new object[] { "Users", "common.users", "/users" }); migrationBuilder.UpdateData( table: "MenuItems", keyColumn: "Id", keyValue: 4, columns: new[] { "Icon", "Name", "Path" }, values: new object[] { "Settings", "common.settings", "/settings" }); } } }