marco.pms.api/Marco.Pms.DataAccess/Migrations/20250331105744_Add_Industry_Table.cs

136 lines
4.5 KiB
C#

using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace Marco.Pms.DataAccess.Migrations
{
/// <inheritdoc />
public partial class Add_Industry_Table : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
//migrationBuilder.DropColumn(
// name: "Role",
// table: "AspNetUsers");
migrationBuilder.AddColumn<int>(
name: "IndustryId",
table: "Tenants",
type: "int",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "IsActive",
table: "Tenants",
type: "tinyint(1)",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "OragnizationSize",
table: "Tenants",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<bool>(
name: "IsActive",
table: "AspNetUsers",
type: "tinyint(1)",
nullable: true);
migrationBuilder.CreateTable(
name: "Industries",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Industries", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.InsertData(
table: "Industries",
columns: new[] { "Id", "Name" },
values: new object[,]
{
{ 1, "Information Technology (IT) Services" },
{ 2, "Manufacturing & Production" },
{ 3, "Energy & Resources" },
{ 4, "Finance & Professional Services" },
{ 5, "Hospitals and Healthcare Services" },
{ 6, "Social Services" },
{ 7, "Retail & Consumer Services" },
{ 8, "Transportation & Logistics" },
{ 9, "Education & Training" }
});
migrationBuilder.UpdateData(
table: "Tenants",
keyColumn: "Id",
keyValue: 1,
columns: new[] { "IndustryId", "IsActive", "OragnizationSize" },
values: new object[] { 1, true, null });
migrationBuilder.CreateIndex(
name: "IX_Tenants_IndustryId",
table: "Tenants",
column: "IndustryId");
migrationBuilder.AddForeignKey(
name: "FK_Tenants_Industries_IndustryId",
table: "Tenants",
column: "IndustryId",
principalTable: "Industries",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Tenants_Industries_IndustryId",
table: "Tenants");
migrationBuilder.DropTable(
name: "Industries");
migrationBuilder.DropIndex(
name: "IX_Tenants_IndustryId",
table: "Tenants");
migrationBuilder.DropColumn(
name: "IndustryId",
table: "Tenants");
migrationBuilder.DropColumn(
name: "IsActive",
table: "Tenants");
migrationBuilder.DropColumn(
name: "OragnizationSize",
table: "Tenants");
migrationBuilder.DropColumn(
name: "IsActive",
table: "AspNetUsers");
migrationBuilder.AddColumn<string>(
name: "Role",
table: "AspNetUsers",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
}
}
}