using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace BMA.EHR.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class updatetablePlacementTransfersaddposition : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<double>(
                name: "AmountOld",
                table: "PlacementTransfers",
                type: "double",
                nullable: true,
                comment: "ข้อมูลหน่วยงานเดิม เงินเดือน");

            migrationBuilder.AddColumn<DateTime>(
                name: "Date",
                table: "PlacementTransfers",
                type: "datetime(6)",
                nullable: true,
                comment: "ตั้งแต่วันที่");

            migrationBuilder.AddColumn<Guid>(
                name: "OrganizationPositionOldId",
                table: "PlacementTransfers",
                type: "char(36)",
                nullable: true,
                collation: "ascii_general_ci");

            migrationBuilder.AddColumn<Guid>(
                name: "PositionLevelOldId",
                table: "PlacementTransfers",
                type: "char(36)",
                nullable: true,
                collation: "ascii_general_ci");

            migrationBuilder.AddColumn<Guid>(
                name: "PositionNumberOldId",
                table: "PlacementTransfers",
                type: "char(36)",
                nullable: true,
                collation: "ascii_general_ci");

            migrationBuilder.AddColumn<Guid>(
                name: "PositionTypeOldId",
                table: "PlacementTransfers",
                type: "char(36)",
                nullable: true,
                collation: "ascii_general_ci");

            migrationBuilder.CreateIndex(
                name: "IX_PlacementTransfers_OrganizationPositionOldId",
                table: "PlacementTransfers",
                column: "OrganizationPositionOldId");

            migrationBuilder.CreateIndex(
                name: "IX_PlacementTransfers_PositionLevelOldId",
                table: "PlacementTransfers",
                column: "PositionLevelOldId");

            migrationBuilder.CreateIndex(
                name: "IX_PlacementTransfers_PositionNumberOldId",
                table: "PlacementTransfers",
                column: "PositionNumberOldId");

            migrationBuilder.CreateIndex(
                name: "IX_PlacementTransfers_PositionTypeOldId",
                table: "PlacementTransfers",
                column: "PositionTypeOldId");

            migrationBuilder.AddForeignKey(
                name: "FK_PlacementTransfers_OrganizationPositions_OrganizationPositio~",
                table: "PlacementTransfers",
                column: "OrganizationPositionOldId",
                principalTable: "OrganizationPositions",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_PlacementTransfers_PositionLevels_PositionLevelOldId",
                table: "PlacementTransfers",
                column: "PositionLevelOldId",
                principalTable: "PositionLevels",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_PlacementTransfers_PositionNumbers_PositionNumberOldId",
                table: "PlacementTransfers",
                column: "PositionNumberOldId",
                principalTable: "PositionNumbers",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_PlacementTransfers_PositionTypes_PositionTypeOldId",
                table: "PlacementTransfers",
                column: "PositionTypeOldId",
                principalTable: "PositionTypes",
                principalColumn: "Id");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_PlacementTransfers_OrganizationPositions_OrganizationPositio~",
                table: "PlacementTransfers");

            migrationBuilder.DropForeignKey(
                name: "FK_PlacementTransfers_PositionLevels_PositionLevelOldId",
                table: "PlacementTransfers");

            migrationBuilder.DropForeignKey(
                name: "FK_PlacementTransfers_PositionNumbers_PositionNumberOldId",
                table: "PlacementTransfers");

            migrationBuilder.DropForeignKey(
                name: "FK_PlacementTransfers_PositionTypes_PositionTypeOldId",
                table: "PlacementTransfers");

            migrationBuilder.DropIndex(
                name: "IX_PlacementTransfers_OrganizationPositionOldId",
                table: "PlacementTransfers");

            migrationBuilder.DropIndex(
                name: "IX_PlacementTransfers_PositionLevelOldId",
                table: "PlacementTransfers");

            migrationBuilder.DropIndex(
                name: "IX_PlacementTransfers_PositionNumberOldId",
                table: "PlacementTransfers");

            migrationBuilder.DropIndex(
                name: "IX_PlacementTransfers_PositionTypeOldId",
                table: "PlacementTransfers");

            migrationBuilder.DropColumn(
                name: "AmountOld",
                table: "PlacementTransfers");

            migrationBuilder.DropColumn(
                name: "Date",
                table: "PlacementTransfers");

            migrationBuilder.DropColumn(
                name: "OrganizationPositionOldId",
                table: "PlacementTransfers");

            migrationBuilder.DropColumn(
                name: "PositionLevelOldId",
                table: "PlacementTransfers");

            migrationBuilder.DropColumn(
                name: "PositionNumberOldId",
                table: "PlacementTransfers");

            migrationBuilder.DropColumn(
                name: "PositionTypeOldId",
                table: "PlacementTransfers");
        }
    }
}
