using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Marco.Pms.DataAccess.Migrations
{
    /// 
    public partial class Added_Directory_Related_Tables : Migration
    {
        /// 
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Buckets",
                columns: table => new
                {
                    Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Name = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    TenantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Buckets", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Buckets_Tenants_TenantId",
                        column: x => x.TenantId,
                        principalTable: "Tenants",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");
            migrationBuilder.CreateTable(
                name: "ContactCategoryMasters",
                columns: table => new
                {
                    Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Name = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    TenantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ContactCategoryMasters", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ContactCategoryMasters_Tenants_TenantId",
                        column: x => x.TenantId,
                        principalTable: "Tenants",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");
            migrationBuilder.CreateTable(
                name: "ContactTagMasters",
                columns: table => new
                {
                    Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Name = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    TenantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ContactTagMasters", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ContactTagMasters_Tenants_TenantId",
                        column: x => x.TenantId,
                        principalTable: "Tenants",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");
            migrationBuilder.CreateTable(
                name: "DirectoryUpdateLogs",
                columns: table => new
                {
                    Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    RefereanceId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    UpdateAt = table.Column(type: "datetime(6)", nullable: false),
                    UpdatedById = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DirectoryUpdateLogs", x => x.Id);
                    table.ForeignKey(
                        name: "FK_DirectoryUpdateLogs_Employees_UpdatedById",
                        column: x => x.UpdatedById,
                        principalTable: "Employees",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");
            migrationBuilder.CreateTable(
                name: "EmployeeBucketMappings",
                columns: table => new
                {
                    Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    BucketId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    EmployeeId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EmployeeBucketMappings", x => x.Id);
                    table.ForeignKey(
                        name: "FK_EmployeeBucketMappings_Buckets_BucketId",
                        column: x => x.BucketId,
                        principalTable: "Buckets",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_EmployeeBucketMappings_Employees_EmployeeId",
                        column: x => x.EmployeeId,
                        principalTable: "Employees",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");
            migrationBuilder.CreateTable(
                name: "Contacts",
                columns: table => new
                {
                    Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    ProjectId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    Name = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Organization = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Address = table.Column(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsActive = table.Column(type: "tinyint(1)", nullable: false),
                    CreatedById = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    ContactCategoryId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    CreatedAt = table.Column(type: "datetime(6)", nullable: false),
                    TenantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Contacts", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Contacts_ContactCategoryMasters_ContactCategoryId",
                        column: x => x.ContactCategoryId,
                        principalTable: "ContactCategoryMasters",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_Contacts_Employees_CreatedById",
                        column: x => x.CreatedById,
                        principalTable: "Employees",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Contacts_Tenants_TenantId",
                        column: x => x.TenantId,
                        principalTable: "Tenants",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");
            migrationBuilder.CreateTable(
                name: "ContactBucketMappings",
                columns: table => new
                {
                    Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    BucketId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    ContactId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ContactBucketMappings", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ContactBucketMappings_Buckets_BucketId",
                        column: x => x.BucketId,
                        principalTable: "Buckets",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ContactBucketMappings_Contacts_ContactId",
                        column: x => x.ContactId,
                        principalTable: "Contacts",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");
            migrationBuilder.CreateTable(
                name: "ContactNotes",
                columns: table => new
                {
                    Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Note = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreatedById = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    CreatedAt = table.Column(type: "datetime(6)", nullable: false),
                    ContactId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    IsActive = table.Column(type: "tinyint(1)", nullable: false),
                    TenantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ContactNotes", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ContactNotes_Contacts_ContactId",
                        column: x => x.ContactId,
                        principalTable: "Contacts",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ContactNotes_Employees_CreatedById",
                        column: x => x.CreatedById,
                        principalTable: "Employees",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ContactNotes_Tenants_TenantId",
                        column: x => x.TenantId,
                        principalTable: "Tenants",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");
            migrationBuilder.CreateTable(
                name: "ContactsEmails",
                columns: table => new
                {
                    Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Label = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    EmailAddress = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ContactId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    IsPrimary = table.Column(type: "tinyint(1)", nullable: false),
                    TenantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ContactsEmails", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ContactsEmails_Contacts_ContactId",
                        column: x => x.ContactId,
                        principalTable: "Contacts",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");
            migrationBuilder.CreateTable(
                name: "ContactsPhones",
                columns: table => new
                {
                    Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Label = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PhoneNumber = table.Column(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ContactId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    IsPrimary = table.Column(type: "tinyint(1)", nullable: false),
                    TenantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ContactsPhones", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ContactsPhones_Contacts_ContactId",
                        column: x => x.ContactId,
                        principalTable: "Contacts",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");
            migrationBuilder.CreateTable(
                name: "ContactTagMappings",
                columns: table => new
                {
                    Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    ContactId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    ContactTagId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ContactTagMappings", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ContactTagMappings_ContactTagMasters_ContactTagId",
                        column: x => x.ContactTagId,
                        principalTable: "ContactTagMasters",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_ContactTagMappings_Contacts_ContactId",
                        column: x => x.ContactId,
                        principalTable: "Contacts",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");
            migrationBuilder.CreateIndex(
                name: "IX_Buckets_TenantId",
                table: "Buckets",
                column: "TenantId");
            migrationBuilder.CreateIndex(
                name: "IX_ContactBucketMappings_BucketId",
                table: "ContactBucketMappings",
                column: "BucketId");
            migrationBuilder.CreateIndex(
                name: "IX_ContactBucketMappings_ContactId",
                table: "ContactBucketMappings",
                column: "ContactId");
            migrationBuilder.CreateIndex(
                name: "IX_ContactCategoryMasters_TenantId",
                table: "ContactCategoryMasters",
                column: "TenantId");
            migrationBuilder.CreateIndex(
                name: "IX_ContactNotes_ContactId",
                table: "ContactNotes",
                column: "ContactId");
            migrationBuilder.CreateIndex(
                name: "IX_ContactNotes_CreatedById",
                table: "ContactNotes",
                column: "CreatedById");
            migrationBuilder.CreateIndex(
                name: "IX_ContactNotes_TenantId",
                table: "ContactNotes",
                column: "TenantId");
            migrationBuilder.CreateIndex(
                name: "IX_Contacts_ContactCategoryId",
                table: "Contacts",
                column: "ContactCategoryId");
            migrationBuilder.CreateIndex(
                name: "IX_Contacts_CreatedById",
                table: "Contacts",
                column: "CreatedById");
            migrationBuilder.CreateIndex(
                name: "IX_Contacts_TenantId",
                table: "Contacts",
                column: "TenantId");
            migrationBuilder.CreateIndex(
                name: "IX_ContactsEmails_ContactId",
                table: "ContactsEmails",
                column: "ContactId");
            migrationBuilder.CreateIndex(
                name: "IX_ContactsPhones_ContactId",
                table: "ContactsPhones",
                column: "ContactId");
            migrationBuilder.CreateIndex(
                name: "IX_ContactTagMappings_ContactId",
                table: "ContactTagMappings",
                column: "ContactId");
            migrationBuilder.CreateIndex(
                name: "IX_ContactTagMappings_ContactTagId",
                table: "ContactTagMappings",
                column: "ContactTagId");
            migrationBuilder.CreateIndex(
                name: "IX_ContactTagMasters_TenantId",
                table: "ContactTagMasters",
                column: "TenantId");
            migrationBuilder.CreateIndex(
                name: "IX_DirectoryUpdateLogs_UpdatedById",
                table: "DirectoryUpdateLogs",
                column: "UpdatedById");
            migrationBuilder.CreateIndex(
                name: "IX_EmployeeBucketMappings_BucketId",
                table: "EmployeeBucketMappings",
                column: "BucketId");
            migrationBuilder.CreateIndex(
                name: "IX_EmployeeBucketMappings_EmployeeId",
                table: "EmployeeBucketMappings",
                column: "EmployeeId");
        }
        /// 
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "ContactBucketMappings");
            migrationBuilder.DropTable(
                name: "ContactNotes");
            migrationBuilder.DropTable(
                name: "ContactsEmails");
            migrationBuilder.DropTable(
                name: "ContactsPhones");
            migrationBuilder.DropTable(
                name: "ContactTagMappings");
            migrationBuilder.DropTable(
                name: "DirectoryUpdateLogs");
            migrationBuilder.DropTable(
                name: "EmployeeBucketMappings");
            migrationBuilder.DropTable(
                name: "ContactTagMasters");
            migrationBuilder.DropTable(
                name: "Contacts");
            migrationBuilder.DropTable(
                name: "Buckets");
            migrationBuilder.DropTable(
                name: "ContactCategoryMasters");
        }
    }
}