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 Added_Tables_Related_To_Organizations : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.UpdateData(
                table: "ActivityMasters",
                keyColumn: "UnitOfMeasurement",
                keyValue: null,
                column: "UnitOfMeasurement",
                value: "");

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

            migrationBuilder.UpdateData(
                table: "ActivityMasters",
                keyColumn: "ActivityName",
                keyValue: null,
                column: "ActivityName",
                value: "");

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

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

            migrationBuilder.AddColumn<bool>(
                name: "IsSystem",
                table: "ActivityMasters",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false);

            migrationBuilder.CreateTable(
                name: "GlobalServiceMasters",
                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"),
                    Description = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_GlobalServiceMasters", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "Organizations",
                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"),
                    Email = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ContactPerson = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Address = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ContactNumber = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SPRID = table.Column<double>(type: "double", nullable: false),
                    CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    CreatedById = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    UpdatedById = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Organizations", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Organizations_Employees_CreatedById",
                        column: x => x.CreatedById,
                        principalTable: "Employees",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_Organizations_Employees_UpdatedById",
                        column: x => x.UpdatedById,
                        principalTable: "Employees",
                        principalColumn: "Id");
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "OrgTypeMasters",
                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_OrgTypeMasters", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "ServiceMasters",
                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"),
                    Description = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsSystem = 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_ServiceMasters", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ServiceMasters_Tenants_TenantId",
                        column: x => x.TenantId,
                        principalTable: "Tenants",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "GlobalActivityGroupMasters",
                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"),
                    Description = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ServiceId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_GlobalActivityGroupMasters", x => x.Id);
                    table.ForeignKey(
                        name: "FK_GlobalActivityGroupMasters_GlobalServiceMasters_ServiceId",
                        column: x => x.ServiceId,
                        principalTable: "GlobalServiceMasters",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "OrgServiceMappings",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    ServiceId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OrgServiceMappings", x => x.Id);
                    table.ForeignKey(
                        name: "FK_OrgServiceMappings_GlobalServiceMasters_ServiceId",
                        column: x => x.ServiceId,
                        principalTable: "GlobalServiceMasters",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_OrgServiceMappings_Organizations_OrganizationId",
                        column: x => x.OrganizationId,
                        principalTable: "Organizations",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "TenantOrgMappings",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    SPRID = table.Column<double>(type: "double", nullable: false),
                    IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    AssignedDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    ReassignedDate = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TenantOrgMappings", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TenantOrgMappings_Organizations_OrganizationId",
                        column: x => x.OrganizationId,
                        principalTable: "Organizations",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_TenantOrgMappings_Tenants_TenantId",
                        column: x => x.TenantId,
                        principalTable: "Tenants",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "ActivityGroupMasters",
                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"),
                    Description = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ServiceId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    IsSystem = 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_ActivityGroupMasters", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ActivityGroupMasters_ServiceMasters_ServiceId",
                        column: x => x.ServiceId,
                        principalTable: "ServiceMasters",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ActivityGroupMasters_Tenants_TenantId",
                        column: x => x.TenantId,
                        principalTable: "Tenants",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "ProjectServiceMappings",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    ServiceId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    ProjectId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    PlannedStartDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    PlannedEndDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    ActualStartDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    ActualEndDate = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProjectServiceMappings", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ProjectServiceMappings_Projects_ProjectId",
                        column: x => x.ProjectId,
                        principalTable: "Projects",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ProjectServiceMappings_ServiceMasters_ServiceId",
                        column: x => x.ServiceId,
                        principalTable: "ServiceMasters",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ProjectServiceMappings_Tenants_TenantId",
                        column: x => x.TenantId,
                        principalTable: "Tenants",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "GlobalActivityMasters",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    ActivityName = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UnitOfMeasurement = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ActivityGroupId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_GlobalActivityMasters", x => x.Id);
                    table.ForeignKey(
                        name: "FK_GlobalActivityMasters_GlobalActivityGroupMasters_ActivityGro~",
                        column: x => x.ActivityGroupId,
                        principalTable: "GlobalActivityGroupMasters",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "ProjectOrgMappings",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    ParentOrganizationId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    ProjectServiceId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    OrganizationTypeId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    AssignedDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    CompletionDate = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProjectOrgMappings", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ProjectOrgMappings_OrgTypeMasters_OrganizationTypeId",
                        column: x => x.OrganizationTypeId,
                        principalTable: "OrgTypeMasters",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ProjectOrgMappings_Organizations_OrganizationId",
                        column: x => x.OrganizationId,
                        principalTable: "Organizations",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ProjectOrgMappings_Organizations_ParentOrganizationId",
                        column: x => x.ParentOrganizationId,
                        principalTable: "Organizations",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ProjectOrgMappings_ProjectServiceMappings_ProjectServiceId",
                        column: x => x.ProjectServiceId,
                        principalTable: "ProjectServiceMappings",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ProjectOrgMappings_Tenants_TenantId",
                        column: x => x.TenantId,
                        principalTable: "Tenants",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.UpdateData(
                table: "DocumentCategoryMasters",
                keyColumn: "Id",
                keyValue: new Guid("2d9fb9cf-db53-476b-a452-492e88e2b51f"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 15, 12, 42, 3, 202, DateTimeKind.Utc));

            migrationBuilder.UpdateData(
                table: "DocumentCategoryMasters",
                keyColumn: "Id",
                keyValue: new Guid("cfbff269-072b-477a-b48b-72cdc57dd1d3"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 15, 12, 42, 3, 202, DateTimeKind.Utc));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("07ca7182-9ac0-4407-b988-59901170cb86"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("16c40b80-c207-4a0c-a4d3-381414afe35a"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("260abd7e-c96d-4ae4-a29b-9b5bb5d24ebd"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("2d1d7441-46a8-425e-9395-94d0956f8e91"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("336225ac-67f3-4e14-ba7a-8fad03cf2832"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("5668de00-5d84-47f7-b9b5-7fefd1219f05"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("6344393b-9bb1-45f8-b620-9f6e279d012c"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("7cc41c91-23cb-442b-badd-f932138d149f"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("846e89a9-5735-45ec-a21d-c97f85a94ada"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("a1a190ba-c4a8-432f-b26d-1231ca1d44bc"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("f76d8215-d399-4f0e-b414-12e427f50be3"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc));

            migrationBuilder.InsertData(
                table: "OrgTypeMasters",
                columns: new[] { "Id", "Name" },
                values: new object[,]
                {
                    { new Guid("5ee49bcd-b6d3-482f-9aaf-484afe04abec"), "Service Provider" },
                    { new Guid("743806fe-d991-4079-b223-e4e2da44f435"), "Tenant" },
                    { new Guid("a283356a-9b02-4029-afb7-e65c703efdd4"), "Sub-Contractor" },
                    { new Guid("b1877a3b-8832-47b1-bbe3-dc7e98672f49"), "PMC" }
                });

            migrationBuilder.InsertData(
                table: "Organizations",
                columns: new[] { "Id", "Address", "ContactNumber", "ContactPerson", "CreatedAt", "CreatedById", "Email", "IsActive", "Name", "SPRID", "UpdatedAt", "UpdatedById" },
                values: new object[] { new Guid("4e3a6d31-c640-40f7-8d67-6c109fcdb9ea"), "2nd Floor, Fullora Building, Tejas CHS, behind Kothrud Stand, Tejas Society, Dahanukar Colony, Kothrud, Pune, Maharashtra 411038", "123456789", "Admin", new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), null, "admin@marcoaiot.com", true, "MarcoBMS", 5400.0, null, null });

            migrationBuilder.CreateIndex(
                name: "IX_ActivityMasters_ActivityGroupId",
                table: "ActivityMasters",
                column: "ActivityGroupId");

            migrationBuilder.CreateIndex(
                name: "IX_ActivityGroupMasters_ServiceId",
                table: "ActivityGroupMasters",
                column: "ServiceId");

            migrationBuilder.CreateIndex(
                name: "IX_ActivityGroupMasters_TenantId",
                table: "ActivityGroupMasters",
                column: "TenantId");

            migrationBuilder.CreateIndex(
                name: "IX_GlobalActivityGroupMasters_ServiceId",
                table: "GlobalActivityGroupMasters",
                column: "ServiceId");

            migrationBuilder.CreateIndex(
                name: "IX_GlobalActivityMasters_ActivityGroupId",
                table: "GlobalActivityMasters",
                column: "ActivityGroupId");

            migrationBuilder.CreateIndex(
                name: "IX_Organizations_CreatedById",
                table: "Organizations",
                column: "CreatedById");

            migrationBuilder.CreateIndex(
                name: "IX_Organizations_UpdatedById",
                table: "Organizations",
                column: "UpdatedById");

            migrationBuilder.CreateIndex(
                name: "IX_OrgServiceMappings_OrganizationId",
                table: "OrgServiceMappings",
                column: "OrganizationId");

            migrationBuilder.CreateIndex(
                name: "IX_OrgServiceMappings_ServiceId",
                table: "OrgServiceMappings",
                column: "ServiceId");

            migrationBuilder.CreateIndex(
                name: "IX_ProjectOrgMappings_OrganizationId",
                table: "ProjectOrgMappings",
                column: "OrganizationId");

            migrationBuilder.CreateIndex(
                name: "IX_ProjectOrgMappings_OrganizationTypeId",
                table: "ProjectOrgMappings",
                column: "OrganizationTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_ProjectOrgMappings_ParentOrganizationId",
                table: "ProjectOrgMappings",
                column: "ParentOrganizationId");

            migrationBuilder.CreateIndex(
                name: "IX_ProjectOrgMappings_ProjectServiceId",
                table: "ProjectOrgMappings",
                column: "ProjectServiceId");

            migrationBuilder.CreateIndex(
                name: "IX_ProjectOrgMappings_TenantId",
                table: "ProjectOrgMappings",
                column: "TenantId");

            migrationBuilder.CreateIndex(
                name: "IX_ProjectServiceMappings_ProjectId",
                table: "ProjectServiceMappings",
                column: "ProjectId");

            migrationBuilder.CreateIndex(
                name: "IX_ProjectServiceMappings_ServiceId",
                table: "ProjectServiceMappings",
                column: "ServiceId");

            migrationBuilder.CreateIndex(
                name: "IX_ProjectServiceMappings_TenantId",
                table: "ProjectServiceMappings",
                column: "TenantId");

            migrationBuilder.CreateIndex(
                name: "IX_ServiceMasters_TenantId",
                table: "ServiceMasters",
                column: "TenantId");

            migrationBuilder.CreateIndex(
                name: "IX_TenantOrgMappings_OrganizationId",
                table: "TenantOrgMappings",
                column: "OrganizationId");

            migrationBuilder.CreateIndex(
                name: "IX_TenantOrgMappings_TenantId",
                table: "TenantOrgMappings",
                column: "TenantId");

            migrationBuilder.AddForeignKey(
                name: "FK_ActivityMasters_ActivityGroupMasters_ActivityGroupId",
                table: "ActivityMasters",
                column: "ActivityGroupId",
                principalTable: "ActivityGroupMasters",
                principalColumn: "Id");
        }

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

            migrationBuilder.DropTable(
                name: "ActivityGroupMasters");

            migrationBuilder.DropTable(
                name: "GlobalActivityMasters");

            migrationBuilder.DropTable(
                name: "OrgServiceMappings");

            migrationBuilder.DropTable(
                name: "ProjectOrgMappings");

            migrationBuilder.DropTable(
                name: "TenantOrgMappings");

            migrationBuilder.DropTable(
                name: "GlobalActivityGroupMasters");

            migrationBuilder.DropTable(
                name: "OrgTypeMasters");

            migrationBuilder.DropTable(
                name: "ProjectServiceMappings");

            migrationBuilder.DropTable(
                name: "Organizations");

            migrationBuilder.DropTable(
                name: "GlobalServiceMasters");

            migrationBuilder.DropTable(
                name: "ServiceMasters");

            migrationBuilder.DropIndex(
                name: "IX_ActivityMasters_ActivityGroupId",
                table: "ActivityMasters");

            migrationBuilder.DropColumn(
                name: "ActivityGroupId",
                table: "ActivityMasters");

            migrationBuilder.DropColumn(
                name: "IsSystem",
                table: "ActivityMasters");

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

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

            migrationBuilder.UpdateData(
                table: "DocumentCategoryMasters",
                keyColumn: "Id",
                keyValue: new Guid("2d9fb9cf-db53-476b-a452-492e88e2b51f"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc).AddTicks(6233));

            migrationBuilder.UpdateData(
                table: "DocumentCategoryMasters",
                keyColumn: "Id",
                keyValue: new Guid("cfbff269-072b-477a-b48b-72cdc57dd1d3"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc).AddTicks(6226));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("07ca7182-9ac0-4407-b988-59901170cb86"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc).AddTicks(6307));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("16c40b80-c207-4a0c-a4d3-381414afe35a"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc).AddTicks(6290));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("260abd7e-c96d-4ae4-a29b-9b5bb5d24ebd"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc).AddTicks(6298));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("2d1d7441-46a8-425e-9395-94d0956f8e91"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc).AddTicks(6286));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("336225ac-67f3-4e14-ba7a-8fad03cf2832"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc).AddTicks(6275));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("5668de00-5d84-47f7-b9b5-7fefd1219f05"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc).AddTicks(6319));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("6344393b-9bb1-45f8-b620-9f6e279d012c"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc).AddTicks(6282));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("7cc41c91-23cb-442b-badd-f932138d149f"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc).AddTicks(6314));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("846e89a9-5735-45ec-a21d-c97f85a94ada"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc).AddTicks(6311));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("a1a190ba-c4a8-432f-b26d-1231ca1d44bc"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc).AddTicks(6302));

            migrationBuilder.UpdateData(
                table: "DocumentTypeMasters",
                keyColumn: "Id",
                keyValue: new Guid("f76d8215-d399-4f0e-b414-12e427f50be3"),
                column: "CreatedAt",
                value: new DateTime(2025, 9, 3, 10, 46, 49, 955, DateTimeKind.Utc).AddTicks(6295));
        }
    }
}
