using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace APT.Data.Migrations.Migrations
{
    public partial class hmr2026040301 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<int>(
                name: "STATUS",
                table: "T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<Guid>(
                name: "APPLY_DEPARTMENT_ID",
                table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION",
                type: "uniqueidentifier",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "APPLY_USER_ID",
                table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION",
                type: "uniqueidentifier",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_T_FO_ENTERPRISE_INFORMATION_REGISTRATION_APPLY_DEPARTMENT_ID",
                table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION",
                column: "APPLY_DEPARTMENT_ID");

            migrationBuilder.CreateIndex(
                name: "IX_T_FO_ENTERPRISE_INFORMATION_REGISTRATION_APPLY_USER_ID",
                table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION",
                column: "APPLY_USER_ID");

            migrationBuilder.AddForeignKey(
                name: "FK_T_FO_ENTERPRISE_INFORMATION_REGISTRATION_T_FM_DEPARTMENT_APPLY_DEPARTMENT_ID",
                table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION",
                column: "APPLY_DEPARTMENT_ID",
                principalTable: "T_FM_DEPARTMENT",
                principalColumn: "ID",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_T_FO_ENTERPRISE_INFORMATION_REGISTRATION_T_FM_USER_APPLY_USER_ID",
                table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION",
                column: "APPLY_USER_ID",
                principalTable: "T_FM_USER",
                principalColumn: "ID",
                onDelete: ReferentialAction.Restrict);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_T_FO_ENTERPRISE_INFORMATION_REGISTRATION_T_FM_DEPARTMENT_APPLY_DEPARTMENT_ID",
                table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION");

            migrationBuilder.DropForeignKey(
                name: "FK_T_FO_ENTERPRISE_INFORMATION_REGISTRATION_T_FM_USER_APPLY_USER_ID",
                table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION");

            migrationBuilder.DropIndex(
                name: "IX_T_FO_ENTERPRISE_INFORMATION_REGISTRATION_APPLY_DEPARTMENT_ID",
                table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION");

            migrationBuilder.DropIndex(
                name: "IX_T_FO_ENTERPRISE_INFORMATION_REGISTRATION_APPLY_USER_ID",
                table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION");

            migrationBuilder.DropColumn(
                name: "STATUS",
                table: "T_SK_MAJOR_ACCIDENT_HAZARD_MANAGE");

            migrationBuilder.DropColumn(
                name: "APPLY_DEPARTMENT_ID",
                table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION");

            migrationBuilder.DropColumn(
                name: "APPLY_USER_ID",
                table: "T_FO_ENTERPRISE_INFORMATION_REGISTRATION");
        }
    }
}
