using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace BMA.EHR.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class addtableplacementtransfer1 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_PlacementReceives_Organizations_OrganizationId",
                table: "PlacementReceives");

            migrationBuilder.RenameColumn(
                name: "OrganizationId",
                table: "PlacementReceives",
                newName: "PositionTypeId");

            migrationBuilder.RenameIndex(
                name: "IX_PlacementReceives_OrganizationId",
                table: "PlacementReceives",
                newName: "IX_PlacementReceives_PositionTypeId");

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

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

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

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

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

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

            migrationBuilder.AddColumn<DateTime>(
                name: "RecruitDate",
                table: "PlacementReceives",
                type: "datetime(6)",
                nullable: true,
                comment: "วันที่บรรจุ");

            migrationBuilder.CreateIndex(
                name: "IX_PlacementReceives_OrganizationPositionId",
                table: "PlacementReceives",
                column: "OrganizationPositionId");

            migrationBuilder.CreateIndex(
                name: "IX_PlacementReceives_PositionLevelId",
                table: "PlacementReceives",
                column: "PositionLevelId");

            migrationBuilder.CreateIndex(
                name: "IX_PlacementReceives_PositionLineId",
                table: "PlacementReceives",
                column: "PositionLineId");

            migrationBuilder.CreateIndex(
                name: "IX_PlacementReceives_PositionNumberId",
                table: "PlacementReceives",
                column: "PositionNumberId");

            migrationBuilder.CreateIndex(
                name: "IX_PlacementReceives_PositionPathId",
                table: "PlacementReceives",
                column: "PositionPathId");

            migrationBuilder.CreateIndex(
                name: "IX_PlacementReceives_PositionPathSideId",
                table: "PlacementReceives",
                column: "PositionPathSideId");

            migrationBuilder.AddForeignKey(
                name: "FK_PlacementReceives_OrganizationPositions_OrganizationPosition~",
                table: "PlacementReceives",
                column: "OrganizationPositionId",
                principalTable: "OrganizationPositions",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_PlacementReceives_PositionLevels_PositionLevelId",
                table: "PlacementReceives",
                column: "PositionLevelId",
                principalTable: "PositionLevels",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_PlacementReceives_PositionLines_PositionLineId",
                table: "PlacementReceives",
                column: "PositionLineId",
                principalTable: "PositionLines",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_PlacementReceives_PositionNumbers_PositionNumberId",
                table: "PlacementReceives",
                column: "PositionNumberId",
                principalTable: "PositionNumbers",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_PlacementReceives_PositionPathSides_PositionPathSideId",
                table: "PlacementReceives",
                column: "PositionPathSideId",
                principalTable: "PositionPathSides",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_PlacementReceives_PositionPaths_PositionPathId",
                table: "PlacementReceives",
                column: "PositionPathId",
                principalTable: "PositionPaths",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_PlacementReceives_PositionTypes_PositionTypeId",
                table: "PlacementReceives",
                column: "PositionTypeId",
                principalTable: "PositionTypes",
                principalColumn: "Id");
        }

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

            migrationBuilder.DropForeignKey(
                name: "FK_PlacementReceives_PositionLevels_PositionLevelId",
                table: "PlacementReceives");

            migrationBuilder.DropForeignKey(
                name: "FK_PlacementReceives_PositionLines_PositionLineId",
                table: "PlacementReceives");

            migrationBuilder.DropForeignKey(
                name: "FK_PlacementReceives_PositionNumbers_PositionNumberId",
                table: "PlacementReceives");

            migrationBuilder.DropForeignKey(
                name: "FK_PlacementReceives_PositionPathSides_PositionPathSideId",
                table: "PlacementReceives");

            migrationBuilder.DropForeignKey(
                name: "FK_PlacementReceives_PositionPaths_PositionPathId",
                table: "PlacementReceives");

            migrationBuilder.DropForeignKey(
                name: "FK_PlacementReceives_PositionTypes_PositionTypeId",
                table: "PlacementReceives");

            migrationBuilder.DropIndex(
                name: "IX_PlacementReceives_OrganizationPositionId",
                table: "PlacementReceives");

            migrationBuilder.DropIndex(
                name: "IX_PlacementReceives_PositionLevelId",
                table: "PlacementReceives");

            migrationBuilder.DropIndex(
                name: "IX_PlacementReceives_PositionLineId",
                table: "PlacementReceives");

            migrationBuilder.DropIndex(
                name: "IX_PlacementReceives_PositionNumberId",
                table: "PlacementReceives");

            migrationBuilder.DropIndex(
                name: "IX_PlacementReceives_PositionPathId",
                table: "PlacementReceives");

            migrationBuilder.DropIndex(
                name: "IX_PlacementReceives_PositionPathSideId",
                table: "PlacementReceives");

            migrationBuilder.DropColumn(
                name: "OrganizationPositionId",
                table: "PlacementReceives");

            migrationBuilder.DropColumn(
                name: "PositionLevelId",
                table: "PlacementReceives");

            migrationBuilder.DropColumn(
                name: "PositionLineId",
                table: "PlacementReceives");

            migrationBuilder.DropColumn(
                name: "PositionNumberId",
                table: "PlacementReceives");

            migrationBuilder.DropColumn(
                name: "PositionPathId",
                table: "PlacementReceives");

            migrationBuilder.DropColumn(
                name: "PositionPathSideId",
                table: "PlacementReceives");

            migrationBuilder.DropColumn(
                name: "RecruitDate",
                table: "PlacementReceives");

            migrationBuilder.RenameColumn(
                name: "PositionTypeId",
                table: "PlacementReceives",
                newName: "OrganizationId");

            migrationBuilder.RenameIndex(
                name: "IX_PlacementReceives_PositionTypeId",
                table: "PlacementReceives",
                newName: "IX_PlacementReceives_OrganizationId");

            migrationBuilder.AddForeignKey(
                name: "FK_PlacementReceives_Organizations_OrganizationId",
                table: "PlacementReceives",
                column: "OrganizationId",
                principalTable: "Organizations",
                principalColumn: "Id");
        }
    }
}
