LingAdmin/Backend/LingAdmin.API/Migrations/20260128084014_InitialCreat...

204 lines
9.3 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace LingAdmin.API.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Languages",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Code = table.Column<string>(type: "nvarchar(max)", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Version = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Languages", x => x.Id);
});
migrationBuilder.CreateTable(
name: "MenuItems",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Path = table.Column<string>(type: "nvarchar(max)", nullable: false),
Icon = table.Column<string>(type: "nvarchar(max)", nullable: false),
Order = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MenuItems", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Requisitions",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ReqNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
Requester = table.Column<string>(type: "nvarchar(max)", nullable: false),
Department = table.Column<string>(type: "nvarchar(max)", nullable: false),
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
Status = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
TotalAmount = table.Column<decimal>(type: "decimal(18,2)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Requisitions", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Translations",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
LanguageCode = table.Column<string>(type: "nvarchar(max)", nullable: false),
Key = table.Column<string>(type: "nvarchar(max)", nullable: false),
Value = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Translations", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
Role = table.Column<string>(type: "nvarchar(max)", nullable: false),
Status = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "RequisitionItems",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
RequisitionId = table.Column<int>(type: "int", nullable: false),
ItemName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Quantity = table.Column<int>(type: "int", nullable: false),
Price = table.Column<decimal>(type: "decimal(18,2)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RequisitionItems", x => x.Id);
table.ForeignKey(
name: "FK_RequisitionItems_Requisitions_RequisitionId",
column: x => x.RequisitionId,
principalTable: "Requisitions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "Languages",
columns: new[] { "Id", "Code", "Name", "Version" },
values: new object[,]
{
{ 1, "en-US", "English", "1.2" },
{ 2, "zh-CN", "简体中文", "1.3" }
});
migrationBuilder.InsertData(
table: "MenuItems",
columns: new[] { "Id", "Icon", "Name", "Order", "Path" },
values: new object[,]
{
{ 1, "LayoutDashboard", "common.dashboard", 1, "/" },
{ 2, "FileText", "common.requisitions", 2, "/requisitions" },
{ 3, "Users", "common.users", 3, "/users" },
{ 4, "Settings", "common.settings", 4, "/settings" }
});
migrationBuilder.InsertData(
table: "Requisitions",
columns: new[] { "Id", "Date", "Department", "Description", "ReqNo", "Requester", "Status", "TotalAmount" },
values: new object[,]
{
{ 101, new DateTime(2023, 10, 25, 0, 0, 0, 0, DateTimeKind.Unspecified), "IT", "Purchase of new laptops for the development team.", "PR-2023001", "John Doe", "Approved", 5000m },
{ 102, new DateTime(2023, 10, 26, 0, 0, 0, 0, DateTimeKind.Unspecified), "HR", "Office supplies for HR department.", "PR-2023002", "Jane Smith", "Pending", 1200m },
{ 103, new DateTime(2023, 10, 27, 0, 0, 0, 0, DateTimeKind.Unspecified), "Sales", "Marketing materials for Q4 campaign.", "PR-2023003", "Bob Johnson", "Draft", 3500m }
});
migrationBuilder.InsertData(
table: "Users",
columns: new[] { "Id", "Email", "Name", "Role", "Status" },
values: new object[,]
{
{ 1, "john@example.com", "John Doe", "Admin", "Active" },
{ 2, "jane@example.com", "Jane Smith", "User", "Inactive" },
{ 3, "bob@example.com", "Bob Johnson", "Editor", "Active" },
{ 4, "alice@example.com", "Alice Williams", "User", "Active" },
{ 5, "charlie@example.com", "Charlie Brown", "User", "Inactive" },
{ 6, "david@example.com", "David Miller", "Admin", "Active" },
{ 7, "eva@example.com", "Eva Davis", "Editor", "Active" },
{ 8, "frank@example.com", "Frank Wilson", "User", "Inactive" },
{ 9, "grace@example.com", "Grace Taylor", "User", "Active" },
{ 10, "henry@example.com", "Henry Anderson", "User", "Active" }
});
migrationBuilder.InsertData(
table: "RequisitionItems",
columns: new[] { "Id", "ItemName", "Price", "Quantity", "RequisitionId" },
values: new object[,]
{
{ 1, "MacBook Pro 16", 2400m, 2, 101 },
{ 2, "Dell Monitor 27", 300m, 5, 101 }
});
migrationBuilder.CreateIndex(
name: "IX_RequisitionItems_RequisitionId",
table: "RequisitionItems",
column: "RequisitionId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Languages");
migrationBuilder.DropTable(
name: "MenuItems");
migrationBuilder.DropTable(
name: "RequisitionItems");
migrationBuilder.DropTable(
name: "Translations");
migrationBuilder.DropTable(
name: "Users");
migrationBuilder.DropTable(
name: "Requisitions");
}
}
}