439 lines
20 KiB
C#
439 lines
20 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Marco.Pms.DataAccess.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Added_Directory_Related_Tables : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Buckets",
|
|
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"),
|
|
TenantId = table.Column<Guid>(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<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"),
|
|
TenantId = table.Column<Guid>(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<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"),
|
|
TenantId = table.Column<Guid>(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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
RefereanceId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
UpdateAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
UpdatedById = table.Column<Guid>(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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
BucketId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
EmployeeId = table.Column<Guid>(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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
ProjectId = table.Column<Guid>(type: "char(36)", nullable: true, 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"),
|
|
Organization = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Address = table.Column<string>(type: "longtext", nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
CreatedById = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
ContactCategoryId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
TenantId = table.Column<Guid>(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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
BucketId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
ContactId = table.Column<Guid>(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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Note = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
CreatedById = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
ContactId = 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_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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Label = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
EmailAddress = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ContactId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
IsPrimary = 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_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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Label = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
PhoneNumber = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
ContactId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
IsPrimary = 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_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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
ContactId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
ContactTagId = table.Column<Guid>(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");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
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");
|
|
}
|
|
}
|
|
}
|