using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

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

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

            migrationBuilder.DropForeignKey(
                name: "FK_PaymentModeMatser_Tenants_TenantId",
                table: "PaymentModeMatser");

            migrationBuilder.DropIndex(
                name: "IX_PaymentModeMatser_TenantId",
                table: "PaymentModeMatser");

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

            migrationBuilder.DeleteData(
                table: "ExpensesTypeMaster",
                keyColumn: "Id",
                keyValue: new Guid("1e2d697a-76b4-4be8-bc66-87144561a1a0"));

            migrationBuilder.DeleteData(
                table: "ExpensesTypeMaster",
                keyColumn: "Id",
                keyValue: new Guid("2de53163-0dbd-404b-8e60-1b02e6b4886a"));

            migrationBuilder.DeleteData(
                table: "ExpensesTypeMaster",
                keyColumn: "Id",
                keyValue: new Guid("4842fa61-64eb-4241-aebd-8282065af9f9"));

            migrationBuilder.DeleteData(
                table: "ExpensesTypeMaster",
                keyColumn: "Id",
                keyValue: new Guid("52484820-1b54-4865-8f0f-baa2b1d339b9"));

            migrationBuilder.DeleteData(
                table: "ExpensesTypeMaster",
                keyColumn: "Id",
                keyValue: new Guid("5e0c6227-d49d-41ff-9f1f-781f0aee2469"));

            migrationBuilder.DeleteData(
                table: "ExpensesTypeMaster",
                keyColumn: "Id",
                keyValue: new Guid("77013784-9324-4d8b-bd36-d6f928e68942"));

            migrationBuilder.DeleteData(
                table: "ExpensesTypeMaster",
                keyColumn: "Id",
                keyValue: new Guid("dd120bc4-ab0a-45ba-8450-5cd45ff221ca"));

            migrationBuilder.DeleteData(
                table: "ExpensesTypeMaster",
                keyColumn: "Id",
                keyValue: new Guid("fc59eb90-98ea-481c-b421-54bfa9e42d8f"));

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

            migrationBuilder.AlterColumn<string>(
                name: "ExpenseUId",
                table: "Expenses",
                type: "longtext",
                nullable: true,
                oldClrType: typeof(string),
                oldType: "longtext")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<double>(
                name: "BaseAmount",
                table: "Expenses",
                type: "double",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "CurrencyId",
                table: "Expenses",
                type: "char(36)",
                nullable: false,
                defaultValue: new Guid("78e96e4a-7ce0-4164-ae3a-c833ad45ec2c"),
                collation: "ascii_general_ci");

            migrationBuilder.AddColumn<Guid>(
                name: "ExpenseCategoryId",
                table: "Expenses",
                type: "char(36)",
                nullable: false,
                defaultValue: new Guid("5e0c6227-d49d-41ff-9f1f-781f0aee2469"),
                collation: "ascii_general_ci");

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

            migrationBuilder.AddColumn<double>(
                name: "TDSPercentage",
                table: "Expenses",
                type: "double",
                nullable: true);

            migrationBuilder.AddColumn<double>(
                name: "TaxAmount",
                table: "Expenses",
                type: "double",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "UIDPostfix",
                table: "Expenses",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<string>(
                name: "UIDPrefix",
                table: "Expenses",
                type: "longtext",
                nullable: false)
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "AdvancePaymentTransactions",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    FinanceUIdPrefix = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    FinanceUIdPostfix = table.Column<int>(type: "int", nullable: false),
                    Title = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ProjectId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    EmployeeId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Amount = table.Column<double>(type: "double", nullable: false),
                    CurrentBalance = table.Column<double>(type: "double", nullable: false),
                    PaidAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    CreatedById = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AdvancePaymentTransactions", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AdvancePaymentTransactions_Employees_CreatedById",
                        column: x => x.CreatedById,
                        principalTable: "Employees",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_AdvancePaymentTransactions_Employees_EmployeeId",
                        column: x => x.EmployeeId,
                        principalTable: "Employees",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_AdvancePaymentTransactions_Projects_ProjectId",
                        column: x => x.ProjectId,
                        principalTable: "Projects",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_AdvancePaymentTransactions_Tenants_TenantId",
                        column: x => x.TenantId,
                        principalTable: "Tenants",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "ExpenseCategoryMasters",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Name = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    NoOfPersonsRequired = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    Description = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    IsAttachmentRequried = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ExpenseCategoryMasters", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ExpenseCategoryMasters_Tenants_TenantId",
                        column: x => x.TenantId,
                        principalTable: "Tenants",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "RecurringPaymentStatus",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Name = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RecurringPaymentStatus", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "StatusUpdateLogs",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    StatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    NextStatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    EntityId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Comment = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    UpdatedById = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_StatusUpdateLogs", x => x.Id);
                    table.ForeignKey(
                        name: "FK_StatusUpdateLogs_Employees_UpdatedById",
                        column: x => x.UpdatedById,
                        principalTable: "Employees",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_StatusUpdateLogs_Tenants_TenantId",
                        column: x => x.TenantId,
                        principalTable: "Tenants",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "RecurringPayments",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Title = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UIDPrefix = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UIDPostfix = table.Column<int>(type: "int", nullable: false),
                    Payee = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    NotifyTo = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CurrencyId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Amount = table.Column<double>(type: "double", nullable: false),
                    StrikeDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    LatestPRGeneratedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    ProjectId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    PaymentBufferDays = table.Column<int>(type: "int", nullable: false),
                    NumberOfIteration = table.Column<int>(type: "int", nullable: false),
                    ExpenseCategoryId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    StatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Frequency = table.Column<int>(type: "int", nullable: false),
                    IsVariable = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    CreatedById = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    UpdatedById = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RecurringPayments", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RecurringPayments_CurrencyMaster_CurrencyId",
                        column: x => x.CurrencyId,
                        principalTable: "CurrencyMaster",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_RecurringPayments_Employees_CreatedById",
                        column: x => x.CreatedById,
                        principalTable: "Employees",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_RecurringPayments_Employees_UpdatedById",
                        column: x => x.UpdatedById,
                        principalTable: "Employees",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_RecurringPayments_ExpenseCategoryMasters_ExpenseCategoryId",
                        column: x => x.ExpenseCategoryId,
                        principalTable: "ExpenseCategoryMasters",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_RecurringPayments_Projects_ProjectId",
                        column: x => x.ProjectId,
                        principalTable: "Projects",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_RecurringPayments_RecurringPaymentStatus_StatusId",
                        column: x => x.StatusId,
                        principalTable: "RecurringPaymentStatus",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_RecurringPayments_Tenants_TenantId",
                        column: x => x.TenantId,
                        principalTable: "Tenants",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "PaymentRequests",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Title = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UIDPrefix = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UIDPostfix = table.Column<int>(type: "int", nullable: false),
                    Payee = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsAdvancePayment = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    CurrencyId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Amount = table.Column<double>(type: "double", nullable: false),
                    BaseAmount = table.Column<double>(type: "double", nullable: true),
                    TaxAmount = table.Column<double>(type: "double", nullable: true),
                    TDSPercentage = table.Column<double>(type: "double", nullable: true),
                    DueDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    ProjectId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    RecurringPaymentId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    ExpenseCategoryId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    ExpenseStatusId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    PaidTransactionId = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PaidAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    PaidById = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    IsExpenseCreated = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    CreatedById = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    UpdatedById = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PaymentRequests", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PaymentRequests_CurrencyMaster_CurrencyId",
                        column: x => x.CurrencyId,
                        principalTable: "CurrencyMaster",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PaymentRequests_Employees_CreatedById",
                        column: x => x.CreatedById,
                        principalTable: "Employees",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PaymentRequests_Employees_PaidById",
                        column: x => x.PaidById,
                        principalTable: "Employees",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_PaymentRequests_Employees_UpdatedById",
                        column: x => x.UpdatedById,
                        principalTable: "Employees",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_PaymentRequests_ExpenseCategoryMasters_ExpenseCategoryId",
                        column: x => x.ExpenseCategoryId,
                        principalTable: "ExpenseCategoryMasters",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_PaymentRequests_ExpensesStatusMaster_ExpenseStatusId",
                        column: x => x.ExpenseStatusId,
                        principalTable: "ExpensesStatusMaster",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PaymentRequests_Projects_ProjectId",
                        column: x => x.ProjectId,
                        principalTable: "Projects",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_PaymentRequests_RecurringPayments_RecurringPaymentId",
                        column: x => x.RecurringPaymentId,
                        principalTable: "RecurringPayments",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_PaymentRequests_Tenants_TenantId",
                        column: x => x.TenantId,
                        principalTable: "Tenants",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "PaymentRequestAttachments",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    PaymentRequestId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    DocumentId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PaymentRequestAttachments", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PaymentRequestAttachments_Documents_DocumentId",
                        column: x => x.DocumentId,
                        principalTable: "Documents",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PaymentRequestAttachments_PaymentRequests_PaymentRequestId",
                        column: x => x.PaymentRequestId,
                        principalTable: "PaymentRequests",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PaymentRequestAttachments_Tenants_TenantId",
                        column: x => x.TenantId,
                        principalTable: "Tenants",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.InsertData(
                table: "ExpenseCategoryMasters",
                columns: new[] { "Id", "Description", "IsActive", "IsAttachmentRequried", "Name", "NoOfPersonsRequired", "TenantId" },
                values: new object[,]
                {
                    { new Guid("1e2d697a-76b4-4be8-bc66-87144561a1a0"), "Scheduled payments for external services or goods.", true, true, "Vendor/Supplier Payments", false, new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
                    { new Guid("2de53163-0dbd-404b-8e60-1b02e6b4886a"), "Vehicle fuel, logistics services and delivery of goods or personnel.", true, false, "Transport", false, new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
                    { new Guid("4842fa61-64eb-4241-aebd-8282065af9f9"), "Government fees, insurance, inspections and safety-related expenditures.", true, true, "Compliance & Safety", false, new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
                    { new Guid("52484820-1b54-4865-8f0f-baa2b1d339b9"), "Site setup costs including equipment deployment and temporary infrastructure.", true, true, "Mobilization", false, new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
                    { new Guid("5e0c6227-d49d-41ff-9f1f-781f0aee2469"), "Materials, equipment and supplies purchased for site operations.", true, true, "Procurement", false, new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
                    { new Guid("77013784-9324-4d8b-bd36-d6f928e68942"), "Machinery servicing, electricity, water, and temporary office needs.", true, true, "Maintenance & Utilities", false, new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
                    { new Guid("dd120bc4-ab0a-45ba-8450-5cd45ff221ca"), "Delivery of personnel.", true, false, "Travelling", true, new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
                    { new Guid("fc59eb90-98ea-481c-b421-54bfa9e42d8f"), " Worker amenities like snacks, meals, safety gear, accommodation, medical support etc.", true, true, "Employee Welfare", true, new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }
                });

            migrationBuilder.UpdateData(
                table: "ExpensesStatusMaster",
                keyColumn: "Id",
                keyValue: new Guid("6537018f-f4e9-4cb3-a210-6c3b2da999d7"),
                column: "DisplayName",
                value: "Submit for Review");

            migrationBuilder.InsertData(
                table: "ExpensesStatusMaster",
                columns: new[] { "Id", "Color", "Description", "DisplayName", "IsActive", "IsSystem", "Name" },
                values: new object[] { new Guid("b8586f67-dc19-49c3-b4af-224149efe1d3"), "#0E9F6E", "Create new Expense.", "Create Expense", true, true, "Done" });

            migrationBuilder.InsertData(
                table: "Features",
                columns: new[] { "Id", "Description", "IsActive", "ModuleId", "Name" },
                values: new object[] { new Guid("86e80017-0698-4efe-93d0-806de67266e0"), "Recurring Template Management is the automated creation and scheduling of repetitive tasks, processes, or transactions using predefined templates at set intervals to ensure consistent and efficient workflow execution without manual recreation each time.", true, new Guid("bf59fd88-b57a-4d67-bf01-3780f385896b"), "Recurring Template Management" });

            migrationBuilder.InsertData(
                table: "Modules",
                columns: new[] { "Id", "Description", "Key", "Name" },
                values: new object[] { new Guid("0a79687a-86d7-430d-a2d7-8b8603cc76a1"), "Finance Module", "504ec132-e6a9-422f-8f85-050602cfce05", "Finance" });

            migrationBuilder.InsertData(
                table: "PaymentModeMatser",
                columns: new[] { "Id", "Description", "IsActive", "Name" },
                values: new object[,]
                {
                    { new Guid("95697409-baf6-4f78-86ab-42d93d9569a8"), "A debit card is a payment card that deducts funds directly from the cardholder's bank account when a purchase is made.", true, "Debit Card" },
                    { new Guid("a820f240-5e9a-4ae9-9091-8a7aa7720cea"), "A credit card is a payment card that allows you to borrow funds from a financial institution to pay for goods and services", true, "Credit card" },
                    { new Guid("f67beee6-6763-4108-922c-03bd86b9178d"), "When a bill is paid using the amount received in advance from a company.", true, "Advance Payment" }
                });

            migrationBuilder.InsertData(
                table: "RecurringPaymentStatus",
                columns: new[] { "Id", "Name" },
                values: new object[,]
                {
                    { new Guid("306856fb-5655-42eb-bf8b-808bb5e84725"), "Completed" },
                    { new Guid("3ec864d2-8bf5-42fb-ba70-5090301dd816"), "De-Activated" },
                    { new Guid("8bfc9346-e092-4a80-acbf-515ae1ef6868"), "Paused" },
                    { new Guid("da462422-13b2-45cc-a175-910a225f6fc8"), "Active" }
                });

            migrationBuilder.InsertData(
                table: "ExpensesStatusMapping",
                columns: new[] { "Id", "NextStatusId", "StatusId" },
                values: new object[] { new Guid("a1cc95ed-b276-4a3e-9f00-0a249b522d64"), new Guid("b8586f67-dc19-49c3-b4af-224149efe1d3"), new Guid("61578360-3a49-4c34-8604-7b35a3787b95") });

            migrationBuilder.InsertData(
                table: "FeaturePermissions",
                columns: new[] { "Id", "Description", "FeatureId", "IsEnabled", "Name" },
                values: new object[,]
                {
                    { new Guid("6382ea8b-aff2-4cd2-a48f-a652b35825d8"), "Manage Recurring Template payment permission allows authorized users to set up, modify, and execute automated recurring payments using predefined templates, ensuring secure and controlled handling of repetitive financial transactions.", new Guid("86e80017-0698-4efe-93d0-806de67266e0"), true, "Manage Recurring" },
                    { new Guid("7ddf2fba-c44d-4fe3-b4ec-690ff70be2e3"), "The \"View All Recurring Template payment permission\" generally allows users to see and access all recurring payment templates in the system, enabling them to review, manage, and process recurring transactions efficiently.", new Guid("86e80017-0698-4efe-93d0-806de67266e0"), true, "View All Recurring" },
                    { new Guid("e5d21efe-573d-4a16-a0f8-414d3e442e78"), "View Self Recurring Template payment permission allows a user to view and access their own recurring payment templates without editing rights.", new Guid("86e80017-0698-4efe-93d0-806de67266e0"), true, "View Self Recurring" }
                });

            migrationBuilder.InsertData(
                table: "StatusPermissionMapping",
                columns: new[] { "Id", "PermissionId", "StatusId" },
                values: new object[] { new Guid("de04b6c7-a5cd-4a61-88b0-b43b0008202e"), new Guid("ea5a1529-4ee8-4828-80ea-0e23c9d4dd11"), new Guid("b8586f67-dc19-49c3-b4af-224149efe1d3") });

            migrationBuilder.CreateIndex(
                name: "IX_Expenses_CurrencyId",
                table: "Expenses",
                column: "CurrencyId");

            migrationBuilder.CreateIndex(
                name: "IX_Expenses_ExpenseCategoryId",
                table: "Expenses",
                column: "ExpenseCategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_Expenses_PaymentRequestId",
                table: "Expenses",
                column: "PaymentRequestId");

            migrationBuilder.CreateIndex(
                name: "IX_AdvancePaymentTransactions_CreatedById",
                table: "AdvancePaymentTransactions",
                column: "CreatedById");

            migrationBuilder.CreateIndex(
                name: "IX_AdvancePaymentTransactions_EmployeeId",
                table: "AdvancePaymentTransactions",
                column: "EmployeeId");

            migrationBuilder.CreateIndex(
                name: "IX_AdvancePaymentTransactions_ProjectId",
                table: "AdvancePaymentTransactions",
                column: "ProjectId");

            migrationBuilder.CreateIndex(
                name: "IX_AdvancePaymentTransactions_TenantId",
                table: "AdvancePaymentTransactions",
                column: "TenantId");

            migrationBuilder.CreateIndex(
                name: "IX_ExpenseCategoryMasters_TenantId",
                table: "ExpenseCategoryMasters",
                column: "TenantId");

            migrationBuilder.CreateIndex(
                name: "IX_PaymentRequestAttachments_DocumentId",
                table: "PaymentRequestAttachments",
                column: "DocumentId");

            migrationBuilder.CreateIndex(
                name: "IX_PaymentRequestAttachments_PaymentRequestId",
                table: "PaymentRequestAttachments",
                column: "PaymentRequestId");

            migrationBuilder.CreateIndex(
                name: "IX_PaymentRequestAttachments_TenantId",
                table: "PaymentRequestAttachments",
                column: "TenantId");

            migrationBuilder.CreateIndex(
                name: "IX_PaymentRequests_CreatedById",
                table: "PaymentRequests",
                column: "CreatedById");

            migrationBuilder.CreateIndex(
                name: "IX_PaymentRequests_CurrencyId",
                table: "PaymentRequests",
                column: "CurrencyId");

            migrationBuilder.CreateIndex(
                name: "IX_PaymentRequests_ExpenseCategoryId",
                table: "PaymentRequests",
                column: "ExpenseCategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_PaymentRequests_ExpenseStatusId",
                table: "PaymentRequests",
                column: "ExpenseStatusId");

            migrationBuilder.CreateIndex(
                name: "IX_PaymentRequests_PaidById",
                table: "PaymentRequests",
                column: "PaidById");

            migrationBuilder.CreateIndex(
                name: "IX_PaymentRequests_ProjectId",
                table: "PaymentRequests",
                column: "ProjectId");

            migrationBuilder.CreateIndex(
                name: "IX_PaymentRequests_RecurringPaymentId",
                table: "PaymentRequests",
                column: "RecurringPaymentId");

            migrationBuilder.CreateIndex(
                name: "IX_PaymentRequests_TenantId",
                table: "PaymentRequests",
                column: "TenantId");

            migrationBuilder.CreateIndex(
                name: "IX_PaymentRequests_UpdatedById",
                table: "PaymentRequests",
                column: "UpdatedById");

            migrationBuilder.CreateIndex(
                name: "IX_RecurringPayments_CreatedById",
                table: "RecurringPayments",
                column: "CreatedById");

            migrationBuilder.CreateIndex(
                name: "IX_RecurringPayments_CurrencyId",
                table: "RecurringPayments",
                column: "CurrencyId");

            migrationBuilder.CreateIndex(
                name: "IX_RecurringPayments_ExpenseCategoryId",
                table: "RecurringPayments",
                column: "ExpenseCategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_RecurringPayments_ProjectId",
                table: "RecurringPayments",
                column: "ProjectId");

            migrationBuilder.CreateIndex(
                name: "IX_RecurringPayments_StatusId",
                table: "RecurringPayments",
                column: "StatusId");

            migrationBuilder.CreateIndex(
                name: "IX_RecurringPayments_TenantId",
                table: "RecurringPayments",
                column: "TenantId");

            migrationBuilder.CreateIndex(
                name: "IX_RecurringPayments_UpdatedById",
                table: "RecurringPayments",
                column: "UpdatedById");

            migrationBuilder.CreateIndex(
                name: "IX_StatusUpdateLogs_TenantId",
                table: "StatusUpdateLogs",
                column: "TenantId");

            migrationBuilder.CreateIndex(
                name: "IX_StatusUpdateLogs_UpdatedById",
                table: "StatusUpdateLogs",
                column: "UpdatedById");

            migrationBuilder.AddForeignKey(
                name: "FK_Expenses_CurrencyMaster_CurrencyId",
                table: "Expenses",
                column: "CurrencyId",
                principalTable: "CurrencyMaster",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Expenses_ExpenseCategoryMasters_ExpenseCategoryId",
                table: "Expenses",
                column: "ExpenseCategoryId",
                principalTable: "ExpenseCategoryMasters",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Expenses_PaymentRequests_PaymentRequestId",
                table: "Expenses",
                column: "PaymentRequestId",
                principalTable: "PaymentRequests",
                principalColumn: "Id");
        }

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

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

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

            migrationBuilder.DropTable(
                name: "AdvancePaymentTransactions");

            migrationBuilder.DropTable(
                name: "PaymentRequestAttachments");

            migrationBuilder.DropTable(
                name: "StatusUpdateLogs");

            migrationBuilder.DropTable(
                name: "PaymentRequests");

            migrationBuilder.DropTable(
                name: "RecurringPayments");

            migrationBuilder.DropTable(
                name: "ExpenseCategoryMasters");

            migrationBuilder.DropTable(
                name: "RecurringPaymentStatus");

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

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

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

            migrationBuilder.DeleteData(
                table: "ExpensesStatusMapping",
                keyColumn: "Id",
                keyValue: new Guid("a1cc95ed-b276-4a3e-9f00-0a249b522d64"));

            migrationBuilder.DeleteData(
                table: "FeaturePermissions",
                keyColumn: "Id",
                keyValue: new Guid("6382ea8b-aff2-4cd2-a48f-a652b35825d8"));

            migrationBuilder.DeleteData(
                table: "FeaturePermissions",
                keyColumn: "Id",
                keyValue: new Guid("7ddf2fba-c44d-4fe3-b4ec-690ff70be2e3"));

            migrationBuilder.DeleteData(
                table: "FeaturePermissions",
                keyColumn: "Id",
                keyValue: new Guid("e5d21efe-573d-4a16-a0f8-414d3e442e78"));

            migrationBuilder.DeleteData(
                table: "Modules",
                keyColumn: "Id",
                keyValue: new Guid("0a79687a-86d7-430d-a2d7-8b8603cc76a1"));

            migrationBuilder.DeleteData(
                table: "PaymentModeMatser",
                keyColumn: "Id",
                keyValue: new Guid("95697409-baf6-4f78-86ab-42d93d9569a8"));

            migrationBuilder.DeleteData(
                table: "PaymentModeMatser",
                keyColumn: "Id",
                keyValue: new Guid("a820f240-5e9a-4ae9-9091-8a7aa7720cea"));

            migrationBuilder.DeleteData(
                table: "PaymentModeMatser",
                keyColumn: "Id",
                keyValue: new Guid("f67beee6-6763-4108-922c-03bd86b9178d"));

            migrationBuilder.DeleteData(
                table: "StatusPermissionMapping",
                keyColumn: "Id",
                keyValue: new Guid("de04b6c7-a5cd-4a61-88b0-b43b0008202e"));

            migrationBuilder.DeleteData(
                table: "ExpensesStatusMaster",
                keyColumn: "Id",
                keyValue: new Guid("b8586f67-dc19-49c3-b4af-224149efe1d3"));

            migrationBuilder.DeleteData(
                table: "Features",
                keyColumn: "Id",
                keyValue: new Guid("86e80017-0698-4efe-93d0-806de67266e0"));

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

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

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

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

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

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

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

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

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

            migrationBuilder.UpdateData(
                table: "Expenses",
                keyColumn: "ExpenseUId",
                keyValue: null,
                column: "ExpenseUId",
                value: "");

            migrationBuilder.AlterColumn<string>(
                name: "ExpenseUId",
                table: "Expenses",
                type: "longtext",
                nullable: false,
                oldClrType: typeof(string),
                oldType: "longtext",
                oldNullable: true)
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.UpdateData(
                table: "ExpensesStatusMaster",
                keyColumn: "Id",
                keyValue: new Guid("6537018f-f4e9-4cb3-a210-6c3b2da999d7"),
                column: "DisplayName",
                value: "Submit");

            migrationBuilder.InsertData(
                table: "ExpensesTypeMaster",
                columns: new[] { "Id", "Description", "IsActive", "IsAttachmentRequried", "Name", "NoOfPersonsRequired", "TenantId" },
                values: new object[,]
                {
                    { new Guid("1e2d697a-76b4-4be8-bc66-87144561a1a0"), "Scheduled payments for external services or goods.", true, true, "Vendor/Supplier Payments", false, new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
                    { new Guid("2de53163-0dbd-404b-8e60-1b02e6b4886a"), "Vehicle fuel, logistics services and delivery of goods or personnel.", true, false, "Transport", false, new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
                    { new Guid("4842fa61-64eb-4241-aebd-8282065af9f9"), "Government fees, insurance, inspections and safety-related expenditures.", true, true, "Compliance & Safety", false, new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
                    { new Guid("52484820-1b54-4865-8f0f-baa2b1d339b9"), "Site setup costs including equipment deployment and temporary infrastructure.", true, true, "Mobilization", false, new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
                    { new Guid("5e0c6227-d49d-41ff-9f1f-781f0aee2469"), "Materials, equipment and supplies purchased for site operations.", true, true, "Procurement", false, new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
                    { new Guid("77013784-9324-4d8b-bd36-d6f928e68942"), "Machinery servicing, electricity, water, and temporary office needs.", true, true, "Maintenance & Utilities", false, new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
                    { new Guid("dd120bc4-ab0a-45ba-8450-5cd45ff221ca"), "Delivery of personnel.", true, false, "Travelling", true, new Guid("b3466e83-7e11-464c-b93a-daf047838b26") },
                    { new Guid("fc59eb90-98ea-481c-b421-54bfa9e42d8f"), " Worker amenities like snacks, meals, safety gear, accommodation, medical support etc.", true, true, "Employee Welfare", true, new Guid("b3466e83-7e11-464c-b93a-daf047838b26") }
                });

            migrationBuilder.UpdateData(
                table: "PaymentModeMatser",
                keyColumn: "Id",
                keyValue: new Guid("24e6b0df-7929-47d2-88a3-4cf14c1f28f9"),
                column: "TenantId",
                value: new Guid("b3466e83-7e11-464c-b93a-daf047838b26"));

            migrationBuilder.UpdateData(
                table: "PaymentModeMatser",
                keyColumn: "Id",
                keyValue: new Guid("2e919e94-694c-41d9-9489-0a2b4208a027"),
                column: "TenantId",
                value: new Guid("b3466e83-7e11-464c-b93a-daf047838b26"));

            migrationBuilder.UpdateData(
                table: "PaymentModeMatser",
                keyColumn: "Id",
                keyValue: new Guid("48d9b462-5d87-4dec-8dec-2bc943943172"),
                column: "TenantId",
                value: new Guid("b3466e83-7e11-464c-b93a-daf047838b26"));

            migrationBuilder.UpdateData(
                table: "PaymentModeMatser",
                keyColumn: "Id",
                keyValue: new Guid("ed667353-8eea-4fd1-8750-719405932480"),
                column: "TenantId",
                value: new Guid("b3466e83-7e11-464c-b93a-daf047838b26"));

            migrationBuilder.CreateIndex(
                name: "IX_PaymentModeMatser_TenantId",
                table: "PaymentModeMatser",
                column: "TenantId");

            migrationBuilder.CreateIndex(
                name: "IX_Expenses_ExpensesTypeId",
                table: "Expenses",
                column: "ExpensesTypeId");

            migrationBuilder.AddForeignKey(
                name: "FK_Expenses_ExpensesTypeMaster_ExpensesTypeId",
                table: "Expenses",
                column: "ExpensesTypeId",
                principalTable: "ExpensesTypeMaster",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

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