using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Marco.Pms.DataAccess.Migrations
{
    /// <inheritdoc />
    public partial class Added_Forgin_Key_For_Approver : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Attendes_Employees_EmployeeID",
                table: "Attendes");

            migrationBuilder.RenameColumn(
                name: "EmployeeID",
                table: "Attendes",
                newName: "EmployeeId");

            migrationBuilder.RenameColumn(
                name: "ApprovedBy",
                table: "Attendes",
                newName: "ApprovedById");

            migrationBuilder.RenameIndex(
                name: "IX_Attendes_EmployeeID",
                table: "Attendes",
                newName: "IX_Attendes_EmployeeId");

            migrationBuilder.CreateIndex(
                name: "IX_Attendes_ApprovedById",
                table: "Attendes",
                column: "ApprovedById");

            migrationBuilder.AddForeignKey(
                name: "FK_Attendes_Employees_ApprovedById",
                table: "Attendes",
                column: "ApprovedById",
                principalTable: "Employees",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Attendes_Employees_EmployeeId",
                table: "Attendes",
                column: "EmployeeId",
                principalTable: "Employees",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

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

            migrationBuilder.DropForeignKey(
                name: "FK_Attendes_Employees_EmployeeId",
                table: "Attendes");

            migrationBuilder.DropIndex(
                name: "IX_Attendes_ApprovedById",
                table: "Attendes");

            migrationBuilder.RenameColumn(
                name: "EmployeeId",
                table: "Attendes",
                newName: "EmployeeID");

            migrationBuilder.RenameColumn(
                name: "ApprovedById",
                table: "Attendes",
                newName: "ApprovedBy");

            migrationBuilder.RenameIndex(
                name: "IX_Attendes_EmployeeId",
                table: "Attendes",
                newName: "IX_Attendes_EmployeeID");

            migrationBuilder.AddForeignKey(
                name: "FK_Attendes_Employees_EmployeeID",
                table: "Attendes",
                column: "EmployeeID",
                principalTable: "Employees",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
