using System; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional namespace Marco.Pms.DataAccess.Migrations { /// public partial class Added_Forum_Tables : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Documents", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), BatchId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), FileName = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), S3Key = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), ThumbS3Key = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), Base64Data = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), FileSize = table.Column(type: "bigint", nullable: false), ContentType = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), UploadedAt = table.Column(type: "datetime(6)", nullable: false), TenantId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Documents", x => x.Id); table.ForeignKey( name: "FK_Documents_Tenants_TenantId", column: x => x.TenantId, principalTable: "Tenants", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "TicketComments", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), TicketId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), AuthorId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), MessageText = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), SentAt = table.Column(type: "datetime(6)", nullable: false), ParentMessageId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), TenantId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TicketComments", x => x.Id); table.ForeignKey( name: "FK_TicketComments_Tenants_TenantId", column: x => x.TenantId, principalTable: "Tenants", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "TicketPriorityMasters", 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"), Level = table.Column(type: "int", nullable: false), ColorCode = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), IsDefault = table.Column(type: "tinyint(1)", nullable: false), TenantId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TicketPriorityMasters", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "TicketStatusMasters", 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: true) .Annotation("MySql:CharSet", "utf8mb4"), ColorCode = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), IsDefault = table.Column(type: "tinyint(1)", nullable: false), TenantId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TicketStatusMasters", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "TicketTagMasters", 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"), ColorCode = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), TenantId = table.Column(type: "int", nullable: false), IsDefault = table.Column(type: "tinyint(1)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TicketTagMasters", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "TicketTypeMasters", 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: true) .Annotation("MySql:CharSet", "utf8mb4"), IsDefault = table.Column(type: "tinyint(1)", nullable: false), TenantId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TicketTypeMasters", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Tickets", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), Subject = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Description = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), StatusId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), TypeId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), CreatedById = table.Column(type: "int", nullable: false), CreatedAt = table.Column(type: "datetime(6)", nullable: false), LinkedActivityId = table.Column(type: "int", nullable: false), PriorityId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), TenantId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Tickets", x => x.Id); table.ForeignKey( name: "FK_Tickets_Tenants_TenantId", column: x => x.TenantId, principalTable: "Tenants", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Tickets_TicketPriorityMasters_PriorityId", column: x => x.PriorityId, principalTable: "TicketPriorityMasters", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Tickets_TicketStatusMasters_StatusId", column: x => x.StatusId, principalTable: "TicketStatusMasters", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Tickets_TicketTypeMasters_TypeId", column: x => x.TypeId, principalTable: "TicketTypeMasters", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "TicketAttachments", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), TicketId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), CommentId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), FileName = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), FileId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_TicketAttachments", x => x.Id); table.ForeignKey( name: "FK_TicketAttachments_TicketComments_CommentId", column: x => x.CommentId, principalTable: "TicketComments", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_TicketAttachments_Tickets_TicketId", column: x => x.TicketId, principalTable: "Tickets", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "TicketTags", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), TicketId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), TagId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_TicketTags", x => x.Id); table.ForeignKey( name: "FK_TicketTags_TicketTagMasters_TagId", column: x => x.TagId, principalTable: "TicketTagMasters", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_TicketTags_Tickets_TicketId", column: x => x.TicketId, principalTable: "Tickets", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.InsertData( table: "TicketPriorityMasters", columns: new[] { "Id", "ColorCode", "IsDefault", "Level", "Name", "TenantId" }, values: new object[,] { { new Guid("0919bc84-9f82-4ecf-98c7-962755dd9a97"), "FFFF00", true, 2, "Medium", 1 }, { new Guid("188d29b3-10f3-42d0-9587-1a46ae7a0320"), "008000", true, 1, "Low", 1 }, { new Guid("44a7b91d-a0dd-45d1-8616-4d2f71e16401"), "#FF0000", true, 5, "Urgent", 1 }, { new Guid("a13b7e59-16fd-4665-b5cf-a97399e8445a"), "#FFA500", true, 3, "High", 1 }, { new Guid("f340fbc3-c9fd-46aa-b063-0093418830e4"), "#FFA500", true, 4, "Critical", 1 } }); migrationBuilder.InsertData( table: "TicketStatusMasters", columns: new[] { "Id", "ColorCode", "Description", "IsDefault", "Name", "TenantId" }, values: new object[,] { { new Guid("5c72b630-6923-4215-bf2c-b1622afd76e7"), "#6c757d", "These issues are currently under review", true, "In Review", 1 }, { new Guid("6b0c409b-3e80-4165-8b39-f3fcacb4c797"), "#FFCC99", "This is a newly created issue.", true, "New", 1 }, { new Guid("6c5ac37d-5b7d-40f3-adec-2dabaa5cca86"), "#E6FF99", "Assigned to employee or team of employees", true, "Assigned", 1 }, { new Guid("7f96bcd5-0c66-411b-8a1d-9d1a4785194e"), "#99E6FF", "These issues are currently in progress", true, "In Progress", 1 }, { new Guid("8ff85685-a875-4f21-aa95-d99551315fcc"), "#B399FF", "The following issues are resolved and closed", true, "Done", 1 } }); migrationBuilder.InsertData( table: "TicketTagMasters", columns: new[] { "Id", "ColorCode", "IsDefault", "Name", "TenantId" }, values: new object[,] { { new Guid("5a168569-8ad7-4422-8db6-51ef25caddeb"), "#85c1e9", true, "Help Desk", 1 }, { new Guid("ef6c2a65-f61d-4537-9650-a7ab7f8d98db"), "#e59866", true, "Quality Issue", 1 } }); migrationBuilder.InsertData( table: "TicketTypeMasters", columns: new[] { "Id", "Description", "IsDefault", "Name", "TenantId" }, values: new object[,] { { new Guid("c74e5480-2b71-483c-8f4a-1a9c69c32603"), "An identified problem that affects the performance, reliability, or standards of a product or service", true, "Quality Issue", 1 }, { new Guid("d1f55eab-9898-4e46-9f03-b263e33e5d38"), "A support service that assists users with technical issues, requests, or inquiries.", true, "Help Desk", 1 } }); migrationBuilder.CreateIndex( name: "IX_Documents_TenantId", table: "Documents", column: "TenantId"); migrationBuilder.CreateIndex( name: "IX_TicketAttachments_CommentId", table: "TicketAttachments", column: "CommentId"); migrationBuilder.CreateIndex( name: "IX_TicketAttachments_TicketId", table: "TicketAttachments", column: "TicketId"); migrationBuilder.CreateIndex( name: "IX_TicketComments_TenantId", table: "TicketComments", column: "TenantId"); migrationBuilder.CreateIndex( name: "IX_Tickets_PriorityId", table: "Tickets", column: "PriorityId"); migrationBuilder.CreateIndex( name: "IX_Tickets_StatusId", table: "Tickets", column: "StatusId"); migrationBuilder.CreateIndex( name: "IX_Tickets_TenantId", table: "Tickets", column: "TenantId"); migrationBuilder.CreateIndex( name: "IX_Tickets_TypeId", table: "Tickets", column: "TypeId"); migrationBuilder.CreateIndex( name: "IX_TicketTags_TagId", table: "TicketTags", column: "TagId"); migrationBuilder.CreateIndex( name: "IX_TicketTags_TicketId", table: "TicketTags", column: "TicketId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Documents"); migrationBuilder.DropTable( name: "TicketAttachments"); migrationBuilder.DropTable( name: "TicketTags"); migrationBuilder.DropTable( name: "TicketComments"); migrationBuilder.DropTable( name: "TicketTagMasters"); migrationBuilder.DropTable( name: "Tickets"); migrationBuilder.DropTable( name: "TicketPriorityMasters"); migrationBuilder.DropTable( name: "TicketStatusMasters"); migrationBuilder.DropTable( name: "TicketTypeMasters"); } } }