using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional

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

            migrationBuilder.DropForeignKey(
                name: "FK_ExpensesStatusMaster_Tenants_TenantId",
                table: "ExpensesStatusMaster");

            migrationBuilder.DropForeignKey(
                name: "FK_StatusPermissionMapping_Tenants_TenantId",
                table: "StatusPermissionMapping");

            migrationBuilder.DropIndex(
                name: "IX_StatusPermissionMapping_TenantId",
                table: "StatusPermissionMapping");

            migrationBuilder.DropIndex(
                name: "IX_ExpensesStatusMaster_TenantId",
                table: "ExpensesStatusMaster");

            migrationBuilder.DropIndex(
                name: "IX_ExpensesStatusMapping_TenantId",
                table: "ExpensesStatusMapping");

            migrationBuilder.DeleteData(
                table: "ExpensesStatusMapping",
                keyColumn: "Id",
                keyValue: new Guid("75bbda6a-6a53-47d1-ad71-5f5f9446a11e"));

            migrationBuilder.DeleteData(
                table: "ExpensesStatusMapping",
                keyColumn: "Id",
                keyValue: new Guid("fddaaf20-4ccc-4f4e-a724-dd310272b356"));

            migrationBuilder.DeleteData(
                table: "StatusPermissionMapping",
                keyColumn: "Id",
                keyValue: new Guid("4652d73f-fc71-4fe1-9f2f-1e48b342d741"));

            migrationBuilder.DeleteData(
                table: "StatusPermissionMapping",
                keyColumn: "Id",
                keyValue: new Guid("ed893799-1a5f-4311-a077-de93c86ca8fd"));

            migrationBuilder.DropColumn(
                name: "TenantId",
                table: "StatusPermissionMapping");

            migrationBuilder.DropColumn(
                name: "TenantId",
                table: "ExpensesStatusMaster");

            migrationBuilder.DropColumn(
                name: "TenantId",
                table: "ExpensesStatusMapping");

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

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

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

            migrationBuilder.InsertData(
                table: "ExpensesStatusMapping",
                columns: new[] { "Id", "NextStatusId", "StatusId" },
                values: new object[] { new Guid("4ddddc10-0ffd-4884-accf-d4fa0bd97f54"), new Guid("6537018f-f4e9-4cb3-a210-6c3b2da999d7"), new Guid("d1ee5eec-24b6-4364-8673-a8f859c60729") });

            migrationBuilder.UpdateData(
                table: "ExpensesStatusMaster",
                keyColumn: "Id",
                keyValue: new Guid("61578360-3a49-4c34-8604-7b35a3787b95"),
                columns: new[] { "DisplayName", "Name" },
                values: new object[] { "Mark as Processed", "Processed" });

            migrationBuilder.UpdateData(
                table: "ExpensesStatusMaster",
                keyColumn: "Id",
                keyValue: new Guid("d1ee5eec-24b6-4364-8673-a8f859c60729"),
                columns: new[] { "Description", "Name" },
                values: new object[] { "Expense was declined, often with a reason(approval rejected).", "Rejected by Approver" });

            migrationBuilder.InsertData(
                table: "ExpensesStatusMaster",
                columns: new[] { "Id", "Color", "Description", "DisplayName", "IsActive", "IsSystem", "Name" },
                values: new object[] { new Guid("965eda62-7907-4963-b4a1-657fb0b2724b"), "#ff3e1d", "Expense was declined, often with a reason(review rejected).", "Reject", true, true, "Rejected by Reviewer" });

            migrationBuilder.InsertData(
                table: "StatusPermissionMapping",
                columns: new[] { "Id", "PermissionId", "StatusId" },
                values: new object[,]
                {
                    { new Guid("0b7926fc-a34b-4a5b-8c7d-1003480cf0fa"), new Guid("1f4bda08-1873-449a-bb66-3e8222bd871b"), new Guid("4068007f-c92f-4f37-a907-bc15fe57d4d8") },
                    { new Guid("722b0c3c-5a78-456d-b9bb-b6ba1b21d59b"), new Guid("0f57885d-bcb2-4711-ac95-d841ace6d5a7"), new Guid("297e0d8f-f668-41b5-bfea-e03b354251c8") },
                    { new Guid("7deb0945-e1c9-411f-8b3c-c9bdbe3c3c2d"), new Guid("0f57885d-bcb2-4711-ac95-d841ace6d5a7"), new Guid("6537018f-f4e9-4cb3-a210-6c3b2da999d7") }
                });

            migrationBuilder.InsertData(
                table: "ExpensesStatusMapping",
                columns: new[] { "Id", "NextStatusId", "StatusId" },
                values: new object[,]
                {
                    { new Guid("6b867bec-66e6-42a7-9611-f4595af9b9ce"), new Guid("965eda62-7907-4963-b4a1-657fb0b2724b"), new Guid("6537018f-f4e9-4cb3-a210-6c3b2da999d7") },
                    { new Guid("9e2ec648-1ca2-4747-9329-e911b18edb3e"), new Guid("6537018f-f4e9-4cb3-a210-6c3b2da999d7"), new Guid("965eda62-7907-4963-b4a1-657fb0b2724b") }
                });

            migrationBuilder.InsertData(
                table: "StatusPermissionMapping",
                columns: new[] { "Id", "PermissionId", "StatusId" },
                values: new object[] { new Guid("9e2ec648-1ca2-4747-9329-e911b18edb3e"), new Guid("1f4bda08-1873-449a-bb66-3e8222bd871b"), new Guid("965eda62-7907-4963-b4a1-657fb0b2724b") });

            migrationBuilder.CreateIndex(
                name: "IX_Expenses_ApprovedById",
                table: "Expenses",
                column: "ApprovedById");

            migrationBuilder.CreateIndex(
                name: "IX_Expenses_ProcessedById",
                table: "Expenses",
                column: "ProcessedById");

            migrationBuilder.CreateIndex(
                name: "IX_Expenses_ReviewedById",
                table: "Expenses",
                column: "ReviewedById");

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

            migrationBuilder.AddForeignKey(
                name: "FK_Expenses_Employees_ProcessedById",
                table: "Expenses",
                column: "ProcessedById",
                principalTable: "Employees",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Expenses_Employees_ReviewedById",
                table: "Expenses",
                column: "ReviewedById",
                principalTable: "Employees",
                principalColumn: "Id");
        }

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

            migrationBuilder.DropForeignKey(
                name: "FK_Expenses_Employees_ProcessedById",
                table: "Expenses");

            migrationBuilder.DropForeignKey(
                name: "FK_Expenses_Employees_ReviewedById",
                table: "Expenses");

            migrationBuilder.DropIndex(
                name: "IX_Expenses_ApprovedById",
                table: "Expenses");

            migrationBuilder.DropIndex(
                name: "IX_Expenses_ProcessedById",
                table: "Expenses");

            migrationBuilder.DropIndex(
                name: "IX_Expenses_ReviewedById",
                table: "Expenses");

            migrationBuilder.DeleteData(
                table: "ExpensesStatusMapping",
                keyColumn: "Id",
                keyValue: new Guid("4ddddc10-0ffd-4884-accf-d4fa0bd97f54"));

            migrationBuilder.DeleteData(
                table: "ExpensesStatusMapping",
                keyColumn: "Id",
                keyValue: new Guid("6b867bec-66e6-42a7-9611-f4595af9b9ce"));

            migrationBuilder.DeleteData(
                table: "ExpensesStatusMapping",
                keyColumn: "Id",
                keyValue: new Guid("9e2ec648-1ca2-4747-9329-e911b18edb3e"));

            migrationBuilder.DeleteData(
                table: "StatusPermissionMapping",
                keyColumn: "Id",
                keyValue: new Guid("0b7926fc-a34b-4a5b-8c7d-1003480cf0fa"));

            migrationBuilder.DeleteData(
                table: "StatusPermissionMapping",
                keyColumn: "Id",
                keyValue: new Guid("722b0c3c-5a78-456d-b9bb-b6ba1b21d59b"));

            migrationBuilder.DeleteData(
                table: "StatusPermissionMapping",
                keyColumn: "Id",
                keyValue: new Guid("7deb0945-e1c9-411f-8b3c-c9bdbe3c3c2d"));

            migrationBuilder.DeleteData(
                table: "StatusPermissionMapping",
                keyColumn: "Id",
                keyValue: new Guid("9e2ec648-1ca2-4747-9329-e911b18edb3e"));

            migrationBuilder.DeleteData(
                table: "ExpensesStatusMaster",
                keyColumn: "Id",
                keyValue: new Guid("965eda62-7907-4963-b4a1-657fb0b2724b"));

            migrationBuilder.DropColumn(
                name: "ApprovedById",
                table: "Expenses");

            migrationBuilder.DropColumn(
                name: "ProcessedById",
                table: "Expenses");

            migrationBuilder.DropColumn(
                name: "ReviewedById",
                table: "Expenses");

            migrationBuilder.AddColumn<Guid>(
                name: "TenantId",
                table: "StatusPermissionMapping",
                type: "char(36)",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
                collation: "ascii_general_ci");

            migrationBuilder.AddColumn<Guid>(
                name: "TenantId",
                table: "ExpensesStatusMaster",
                type: "char(36)",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
                collation: "ascii_general_ci");

            migrationBuilder.AddColumn<Guid>(
                name: "TenantId",
                table: "ExpensesStatusMapping",
                type: "char(36)",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
                collation: "ascii_general_ci");

            migrationBuilder.UpdateData(
                table: "ExpensesStatusMapping",
                keyColumn: "Id",
                keyValue: new Guid("1fca1700-1266-477d-bba4-9ac3753aa33c"),
                column: "TenantId",
                value: new Guid("b3466e83-7e11-464c-b93a-daf047838b26"));

            migrationBuilder.UpdateData(
                table: "ExpensesStatusMapping",
                keyColumn: "Id",
                keyValue: new Guid("36c00548-241c-43ec-bc95-cacebedb925c"),
                column: "TenantId",
                value: new Guid("b3466e83-7e11-464c-b93a-daf047838b26"));

            migrationBuilder.UpdateData(
                table: "ExpensesStatusMapping",
                keyColumn: "Id",
                keyValue: new Guid("5cf7f1df-9d1f-4289-add0-1775ad614f25"),
                column: "TenantId",
                value: new Guid("b3466e83-7e11-464c-b93a-daf047838b26"));

            migrationBuilder.UpdateData(
                table: "ExpensesStatusMapping",
                keyColumn: "Id",
                keyValue: new Guid("af1e4492-98ee-4451-8ab7-fd8323f29c32"),
                column: "TenantId",
                value: new Guid("b3466e83-7e11-464c-b93a-daf047838b26"));

            migrationBuilder.UpdateData(
                table: "ExpensesStatusMapping",
                keyColumn: "Id",
                keyValue: new Guid("ef1fcfbc-60e0-4f17-9308-c583a05d48fd"),
                column: "TenantId",
                value: new Guid("b3466e83-7e11-464c-b93a-daf047838b26"));

            migrationBuilder.InsertData(
                table: "ExpensesStatusMapping",
                columns: new[] { "Id", "NextStatusId", "StatusId", "TenantId" },
                values: new object[,]
                {
                    { new Guid("75bbda6a-6a53-47d1-ad71-5f5f9446a11e"), new Guid("6537018f-f4e9-4cb3-a210-6c3b2da999d7"), new Guid("d1ee5eec-24b6-4364-8673-a8f859c60729"), new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
                    { new Guid("fddaaf20-4ccc-4f4e-a724-dd310272b356"), new Guid("d1ee5eec-24b6-4364-8673-a8f859c60729"), new Guid("6537018f-f4e9-4cb3-a210-6c3b2da999d7"), new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }
                });

            migrationBuilder.UpdateData(
                table: "ExpensesStatusMaster",
                keyColumn: "Id",
                keyValue: new Guid("297e0d8f-f668-41b5-bfea-e03b354251c8"),
                column: "TenantId",
                value: new Guid("b3466e83-7e11-464c-b93a-daf047838b26"));

            migrationBuilder.UpdateData(
                table: "ExpensesStatusMaster",
                keyColumn: "Id",
                keyValue: new Guid("4068007f-c92f-4f37-a907-bc15fe57d4d8"),
                column: "TenantId",
                value: new Guid("b3466e83-7e11-464c-b93a-daf047838b26"));

            migrationBuilder.UpdateData(
                table: "ExpensesStatusMaster",
                keyColumn: "Id",
                keyValue: new Guid("61578360-3a49-4c34-8604-7b35a3787b95"),
                columns: new[] { "DisplayName", "Name", "TenantId" },
                values: new object[] { "Mark as Paid", "Paid", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") });

            migrationBuilder.UpdateData(
                table: "ExpensesStatusMaster",
                keyColumn: "Id",
                keyValue: new Guid("6537018f-f4e9-4cb3-a210-6c3b2da999d7"),
                column: "TenantId",
                value: new Guid("b3466e83-7e11-464c-b93a-daf047838b26"));

            migrationBuilder.UpdateData(
                table: "ExpensesStatusMaster",
                keyColumn: "Id",
                keyValue: new Guid("d1ee5eec-24b6-4364-8673-a8f859c60729"),
                columns: new[] { "Description", "Name", "TenantId" },
                values: new object[] { "Expense was declined, often with a reason(either review rejected or approval rejected.", "Rejected", new Guid("b3466e83-7e11-464c-b93a-daf047838b26") });

            migrationBuilder.UpdateData(
                table: "ExpensesStatusMaster",
                keyColumn: "Id",
                keyValue: new Guid("f18c5cfd-7815-4341-8da2-2c2d65778e27"),
                column: "TenantId",
                value: new Guid("b3466e83-7e11-464c-b93a-daf047838b26"));

            migrationBuilder.UpdateData(
                table: "StatusPermissionMapping",
                keyColumn: "Id",
                keyValue: new Guid("214354e5-daad-4569-ad69-eb5bf4e87fbc"),
                column: "TenantId",
                value: new Guid("b3466e83-7e11-464c-b93a-daf047838b26"));

            migrationBuilder.UpdateData(
                table: "StatusPermissionMapping",
                keyColumn: "Id",
                keyValue: new Guid("cd15f9b9-be45-4deb-9c71-2f23f872dbcd"),
                column: "TenantId",
                value: new Guid("b3466e83-7e11-464c-b93a-daf047838b26"));

            migrationBuilder.UpdateData(
                table: "StatusPermissionMapping",
                keyColumn: "Id",
                keyValue: new Guid("f6f26b2f-2fa6-40b7-8601-cbd4bcdda0cc"),
                column: "TenantId",
                value: new Guid("b3466e83-7e11-464c-b93a-daf047838b26"));

            migrationBuilder.InsertData(
                table: "StatusPermissionMapping",
                columns: new[] { "Id", "PermissionId", "StatusId", "TenantId" },
                values: new object[,]
                {
                    { new Guid("4652d73f-fc71-4fe1-9f2f-1e48b342d741"), new Guid("1f4bda08-1873-449a-bb66-3e8222bd871b"), new Guid("d1ee5eec-24b6-4364-8673-a8f859c60729"), new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
                    { new Guid("ed893799-1a5f-4311-a077-de93c86ca8fd"), new Guid("1f4bda08-1873-449a-bb66-3e8222bd871b"), new Guid("4068007f-c92f-4f37-a907-bc15fe57d4d8"), new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }
                });

            migrationBuilder.CreateIndex(
                name: "IX_StatusPermissionMapping_TenantId",
                table: "StatusPermissionMapping",
                column: "TenantId");

            migrationBuilder.CreateIndex(
                name: "IX_ExpensesStatusMaster_TenantId",
                table: "ExpensesStatusMaster",
                column: "TenantId");

            migrationBuilder.CreateIndex(
                name: "IX_ExpensesStatusMapping_TenantId",
                table: "ExpensesStatusMapping",
                column: "TenantId");

            migrationBuilder.AddForeignKey(
                name: "FK_ExpensesStatusMapping_Tenants_TenantId",
                table: "ExpensesStatusMapping",
                column: "TenantId",
                principalTable: "Tenants",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ExpensesStatusMaster_Tenants_TenantId",
                table: "ExpensesStatusMaster",
                column: "TenantId",
                principalTable: "Tenants",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_StatusPermissionMapping_Tenants_TenantId",
                table: "StatusPermissionMapping",
                column: "TenantId",
                principalTable: "Tenants",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
