20240225115219_UserTasks.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
  5. namespace MTWorkHR.Infrastructure.Migrations
  6. {
  7. /// <inheritdoc />
  8. public partial class UserTasks : Migration
  9. {
  10. /// <inheritdoc />
  11. protected override void Up(MigrationBuilder migrationBuilder)
  12. {
  13. migrationBuilder.CreateTable(
  14. name: "AttachmentType",
  15. columns: table => new
  16. {
  17. Id = table.Column<long>(type: "bigint", nullable: false)
  18. .Annotation("SqlServer:Identity", "1, 1"),
  19. NameAr = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  20. NameEn = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  21. IsRequired = table.Column<bool>(type: "bit", nullable: false)
  22. },
  23. constraints: table =>
  24. {
  25. table.PrimaryKey("PK_AttachmentType", x => x.Id);
  26. });
  27. migrationBuilder.CreateTable(
  28. name: "Projects",
  29. columns: table => new
  30. {
  31. Id = table.Column<long>(type: "bigint", nullable: false)
  32. .Annotation("SqlServer:Identity", "1, 1"),
  33. NameAr = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  34. NameEn = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false)
  35. },
  36. constraints: table =>
  37. {
  38. table.PrimaryKey("PK_Projects", x => x.Id);
  39. });
  40. migrationBuilder.CreateTable(
  41. name: "UserTaskStatuses",
  42. columns: table => new
  43. {
  44. Id = table.Column<long>(type: "bigint", nullable: false)
  45. .Annotation("SqlServer:Identity", "1, 1"),
  46. NameAr = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  47. NameEn = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false)
  48. },
  49. constraints: table =>
  50. {
  51. table.PrimaryKey("PK_UserTaskStatuses", x => x.Id);
  52. });
  53. migrationBuilder.CreateTable(
  54. name: "UserTaskHistories",
  55. columns: table => new
  56. {
  57. Id = table.Column<long>(type: "bigint", nullable: false)
  58. .Annotation("SqlServer:Identity", "1, 1"),
  59. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  60. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  61. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  62. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  63. AssignedToUserId = table.Column<long>(type: "bigint", nullable: false),
  64. Comment = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
  65. CurrentStatusId = table.Column<long>(type: "bigint", nullable: false),
  66. IsDeleted = table.Column<bool>(type: "bit", nullable: false)
  67. },
  68. constraints: table =>
  69. {
  70. table.PrimaryKey("PK_UserTaskHistories", x => x.Id);
  71. table.ForeignKey(
  72. name: "FK_UserTaskHistories_UserTaskStatuses_CurrentStatusId",
  73. column: x => x.CurrentStatusId,
  74. principalTable: "UserTaskStatuses",
  75. principalColumn: "Id",
  76. onDelete: ReferentialAction.Cascade);
  77. });
  78. migrationBuilder.CreateTable(
  79. name: "UserTasks",
  80. columns: table => new
  81. {
  82. Id = table.Column<long>(type: "bigint", nullable: false)
  83. .Annotation("SqlServer:Identity", "1, 1"),
  84. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  85. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  86. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  87. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  88. IsDeleted = table.Column<bool>(type: "bit", nullable: false),
  89. DeleteUserId = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: false),
  90. AssignedUserId = table.Column<long>(type: "bigint", nullable: false),
  91. Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
  92. Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
  93. DueDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  94. Priority = table.Column<int>(type: "int", nullable: false),
  95. ProjectId = table.Column<long>(type: "bigint", nullable: false),
  96. StatusId = table.Column<long>(type: "bigint", nullable: false)
  97. },
  98. constraints: table =>
  99. {
  100. table.PrimaryKey("PK_UserTasks", x => x.Id);
  101. table.ForeignKey(
  102. name: "FK_UserTasks_Projects_ProjectId",
  103. column: x => x.ProjectId,
  104. principalTable: "Projects",
  105. principalColumn: "Id",
  106. onDelete: ReferentialAction.Cascade);
  107. table.ForeignKey(
  108. name: "FK_UserTasks_UserTaskStatuses_StatusId",
  109. column: x => x.StatusId,
  110. principalTable: "UserTaskStatuses",
  111. principalColumn: "Id",
  112. onDelete: ReferentialAction.Cascade);
  113. });
  114. migrationBuilder.CreateTable(
  115. name: "UserTaskAttachments",
  116. columns: table => new
  117. {
  118. Id = table.Column<long>(type: "bigint", nullable: false)
  119. .Annotation("SqlServer:Identity", "1, 1"),
  120. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  121. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  122. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  123. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  124. TaskId = table.Column<long>(type: "bigint", nullable: false),
  125. AttachmentTypeId = table.Column<long>(type: "bigint", nullable: false),
  126. FileName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  127. OriginalName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false)
  128. },
  129. constraints: table =>
  130. {
  131. table.PrimaryKey("PK_UserTaskAttachments", x => x.Id);
  132. table.ForeignKey(
  133. name: "FK_UserTaskAttachments_AttachmentType_AttachmentTypeId",
  134. column: x => x.AttachmentTypeId,
  135. principalTable: "AttachmentType",
  136. principalColumn: "Id",
  137. onDelete: ReferentialAction.Cascade);
  138. table.ForeignKey(
  139. name: "FK_UserTaskAttachments_UserTasks_TaskId",
  140. column: x => x.TaskId,
  141. principalTable: "UserTasks",
  142. principalColumn: "Id",
  143. onDelete: ReferentialAction.Cascade);
  144. });
  145. migrationBuilder.InsertData(
  146. table: "AttachmentType",
  147. columns: new[] { "Id", "IsRequired", "NameAr", "NameEn" },
  148. values: new object[,]
  149. {
  150. { 1L, false, "السيرة الذاتية", "CV" },
  151. { 2L, false, "الهوية", "Identification" }
  152. });
  153. migrationBuilder.CreateIndex(
  154. name: "IX_UserTaskAttachments_AttachmentTypeId",
  155. table: "UserTaskAttachments",
  156. column: "AttachmentTypeId");
  157. migrationBuilder.CreateIndex(
  158. name: "IX_UserTaskAttachments_TaskId",
  159. table: "UserTaskAttachments",
  160. column: "TaskId");
  161. migrationBuilder.CreateIndex(
  162. name: "IX_UserTaskHistories_CurrentStatusId",
  163. table: "UserTaskHistories",
  164. column: "CurrentStatusId");
  165. migrationBuilder.CreateIndex(
  166. name: "IX_UserTasks_ProjectId",
  167. table: "UserTasks",
  168. column: "ProjectId");
  169. migrationBuilder.CreateIndex(
  170. name: "IX_UserTasks_StatusId",
  171. table: "UserTasks",
  172. column: "StatusId");
  173. }
  174. /// <inheritdoc />
  175. protected override void Down(MigrationBuilder migrationBuilder)
  176. {
  177. migrationBuilder.DropTable(
  178. name: "UserTaskAttachments");
  179. migrationBuilder.DropTable(
  180. name: "UserTaskHistories");
  181. migrationBuilder.DropTable(
  182. name: "AttachmentType");
  183. migrationBuilder.DropTable(
  184. name: "UserTasks");
  185. migrationBuilder.DropTable(
  186. name: "Projects");
  187. migrationBuilder.DropTable(
  188. name: "UserTaskStatuses");
  189. }
  190. }
  191. }