20241015091013_contractTbls.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace MTWorkHR.Infrastructure.Migrations
  5. {
  6. /// <inheritdoc />
  7. public partial class contractTbls : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.CreateTable(
  13. name: "Contracts",
  14. columns: table => new
  15. {
  16. Id = table.Column<long>(type: "bigint", nullable: false)
  17. .Annotation("SqlServer:Identity", "1, 1"),
  18. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  19. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  20. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  21. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  22. IsDeleted = table.Column<bool>(type: "bit", nullable: false),
  23. DeleteUserId = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  24. ContractTypeId = table.Column<int>(type: "int", nullable: false),
  25. CompanyId = table.Column<long>(type: "bigint", nullable: false),
  26. CompanyRepresentativeId = table.Column<string>(type: "nvarchar(max)", nullable: false),
  27. UserId = table.Column<string>(type: "nvarchar(max)", nullable: false),
  28. JobId = table.Column<int>(type: "int", nullable: true),
  29. AcademicQualificationId = table.Column<int>(type: "int", nullable: true),
  30. SpecializationId = table.Column<int>(type: "int", nullable: true),
  31. WorkCountryId = table.Column<int>(type: "int", nullable: false),
  32. WorkStateId = table.Column<int>(type: "int", nullable: false),
  33. JobTitleId = table.Column<int>(type: "int", nullable: true),
  34. JobDescription = table.Column<string>(type: "nvarchar(max)", nullable: true),
  35. JobNumber = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: true),
  36. StartDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  37. EndDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  38. ContractDurationId = table.Column<int>(type: "int", nullable: false),
  39. TypeOfWork = table.Column<int>(type: "int", nullable: false),
  40. VacationDays = table.Column<int>(type: "int", nullable: false),
  41. TrialPeriod = table.Column<int>(type: "int", nullable: false),
  42. WhoCanTerminateContractInTrial = table.Column<int>(type: "int", nullable: false),
  43. WhoCanTerminateContract = table.Column<int>(type: "int", nullable: false),
  44. NoticePeriodBeforeTermination = table.Column<int>(type: "int", nullable: false),
  45. WorkingDays = table.Column<string>(type: "nvarchar(max)", nullable: false),
  46. WorkingHours = table.Column<int>(type: "int", nullable: false),
  47. StartDailyWorkingHours = table.Column<DateTime>(type: "datetime2", nullable: true),
  48. EndDailyWorkingHours = table.Column<DateTime>(type: "datetime2", nullable: true),
  49. Currency = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  50. Salary = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
  51. BillingCycle = table.Column<int>(type: "int", nullable: false),
  52. IncludesAllAllowances = table.Column<bool>(type: "bit", nullable: false)
  53. },
  54. constraints: table =>
  55. {
  56. table.PrimaryKey("PK_Contracts", x => x.Id);
  57. });
  58. migrationBuilder.CreateTable(
  59. name: "ContractAllowance",
  60. columns: table => new
  61. {
  62. Id = table.Column<long>(type: "bigint", nullable: false)
  63. .Annotation("SqlServer:Identity", "1, 1"),
  64. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  65. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  66. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  67. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  68. ContractId = table.Column<long>(type: "bigint", nullable: false),
  69. AllowanceType = table.Column<long>(type: "bigint", nullable: false),
  70. AllowanceDesc = table.Column<string>(type: "nvarchar(max)", nullable: true),
  71. EntitlementPercent = table.Column<long>(type: "bigint", nullable: false),
  72. EntitlementAmount = table.Column<long>(type: "bigint", nullable: false),
  73. PaymentType = table.Column<int>(type: "int", nullable: false)
  74. },
  75. constraints: table =>
  76. {
  77. table.PrimaryKey("PK_ContractAllowance", x => x.Id);
  78. table.ForeignKey(
  79. name: "FK_ContractAllowance_Contracts_ContractId",
  80. column: x => x.ContractId,
  81. principalTable: "Contracts",
  82. principalColumn: "Id",
  83. onDelete: ReferentialAction.Cascade);
  84. });
  85. migrationBuilder.CreateTable(
  86. name: "ContractTask",
  87. columns: table => new
  88. {
  89. Id = table.Column<long>(type: "bigint", nullable: false)
  90. .Annotation("SqlServer:Identity", "1, 1"),
  91. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  92. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  93. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  94. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  95. ContractId = table.Column<long>(type: "bigint", nullable: false),
  96. Title = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  97. StartDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  98. Amount = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
  99. ScopeOfWork = table.Column<string>(type: "nvarchar(max)", nullable: true)
  100. },
  101. constraints: table =>
  102. {
  103. table.PrimaryKey("PK_ContractTask", x => x.Id);
  104. table.ForeignKey(
  105. name: "FK_ContractTask_Contracts_ContractId",
  106. column: x => x.ContractId,
  107. principalTable: "Contracts",
  108. principalColumn: "Id",
  109. onDelete: ReferentialAction.Cascade);
  110. });
  111. migrationBuilder.CreateTable(
  112. name: "ProjectStage",
  113. columns: table => new
  114. {
  115. Id = table.Column<long>(type: "bigint", nullable: false)
  116. .Annotation("SqlServer:Identity", "1, 1"),
  117. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  118. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  119. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  120. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  121. ContractId = table.Column<long>(type: "bigint", nullable: false),
  122. Title = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  123. StartDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  124. ExpectedEndDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  125. AmountPercent = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
  126. ScopeOfWork = table.Column<string>(type: "nvarchar(max)", nullable: true)
  127. },
  128. constraints: table =>
  129. {
  130. table.PrimaryKey("PK_ProjectStage", x => x.Id);
  131. table.ForeignKey(
  132. name: "FK_ProjectStage_Contracts_ContractId",
  133. column: x => x.ContractId,
  134. principalTable: "Contracts",
  135. principalColumn: "Id",
  136. onDelete: ReferentialAction.Cascade);
  137. });
  138. migrationBuilder.CreateTable(
  139. name: "ContractTaskAttachment",
  140. columns: table => new
  141. {
  142. Id = table.Column<long>(type: "bigint", nullable: false)
  143. .Annotation("SqlServer:Identity", "1, 1"),
  144. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  145. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  146. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  147. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  148. ContractTaskId = table.Column<long>(type: "bigint", nullable: false),
  149. AttachmentTypeId = table.Column<long>(type: "bigint", nullable: true),
  150. FileName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: true),
  151. OriginalName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: true),
  152. Content = table.Column<byte[]>(type: "varbinary(max)", nullable: false),
  153. FilePath = table.Column<string>(type: "nvarchar(max)", nullable: true),
  154. ContentType = table.Column<string>(type: "nvarchar(max)", nullable: true)
  155. },
  156. constraints: table =>
  157. {
  158. table.PrimaryKey("PK_ContractTaskAttachment", x => x.Id);
  159. table.ForeignKey(
  160. name: "FK_ContractTaskAttachment_AttachmentTypes_AttachmentTypeId",
  161. column: x => x.AttachmentTypeId,
  162. principalTable: "AttachmentTypes",
  163. principalColumn: "Id");
  164. table.ForeignKey(
  165. name: "FK_ContractTaskAttachment_ContractTask_ContractTaskId",
  166. column: x => x.ContractTaskId,
  167. principalTable: "ContractTask",
  168. principalColumn: "Id",
  169. onDelete: ReferentialAction.Cascade);
  170. });
  171. migrationBuilder.CreateTable(
  172. name: "ProjectStageAttachment",
  173. columns: table => new
  174. {
  175. Id = table.Column<long>(type: "bigint", nullable: false)
  176. .Annotation("SqlServer:Identity", "1, 1"),
  177. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  178. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  179. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  180. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  181. ProjectStageId = table.Column<long>(type: "bigint", nullable: false),
  182. AttachmentTypeId = table.Column<long>(type: "bigint", nullable: true),
  183. FileName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: true),
  184. OriginalName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: true),
  185. Content = table.Column<byte[]>(type: "varbinary(max)", nullable: false),
  186. FilePath = table.Column<string>(type: "nvarchar(max)", nullable: true),
  187. ContentType = table.Column<string>(type: "nvarchar(max)", nullable: true)
  188. },
  189. constraints: table =>
  190. {
  191. table.PrimaryKey("PK_ProjectStageAttachment", x => x.Id);
  192. table.ForeignKey(
  193. name: "FK_ProjectStageAttachment_AttachmentTypes_AttachmentTypeId",
  194. column: x => x.AttachmentTypeId,
  195. principalTable: "AttachmentTypes",
  196. principalColumn: "Id");
  197. table.ForeignKey(
  198. name: "FK_ProjectStageAttachment_ProjectStage_ProjectStageId",
  199. column: x => x.ProjectStageId,
  200. principalTable: "ProjectStage",
  201. principalColumn: "Id",
  202. onDelete: ReferentialAction.Cascade);
  203. });
  204. migrationBuilder.CreateIndex(
  205. name: "IX_ContractAllowance_ContractId",
  206. table: "ContractAllowance",
  207. column: "ContractId");
  208. migrationBuilder.CreateIndex(
  209. name: "IX_Contracts_CompanyId",
  210. table: "Contracts",
  211. column: "CompanyId");
  212. migrationBuilder.CreateIndex(
  213. name: "IX_ContractTask_ContractId",
  214. table: "ContractTask",
  215. column: "ContractId");
  216. migrationBuilder.CreateIndex(
  217. name: "IX_ContractTaskAttachment_AttachmentTypeId",
  218. table: "ContractTaskAttachment",
  219. column: "AttachmentTypeId");
  220. migrationBuilder.CreateIndex(
  221. name: "IX_ContractTaskAttachment_ContractTaskId",
  222. table: "ContractTaskAttachment",
  223. column: "ContractTaskId");
  224. migrationBuilder.CreateIndex(
  225. name: "IX_ProjectStage_ContractId",
  226. table: "ProjectStage",
  227. column: "ContractId");
  228. migrationBuilder.CreateIndex(
  229. name: "IX_ProjectStageAttachment_AttachmentTypeId",
  230. table: "ProjectStageAttachment",
  231. column: "AttachmentTypeId");
  232. migrationBuilder.CreateIndex(
  233. name: "IX_ProjectStageAttachment_ProjectStageId",
  234. table: "ProjectStageAttachment",
  235. column: "ProjectStageId");
  236. }
  237. /// <inheritdoc />
  238. protected override void Down(MigrationBuilder migrationBuilder)
  239. {
  240. migrationBuilder.DropTable(
  241. name: "ContractAllowance");
  242. migrationBuilder.DropTable(
  243. name: "ContractTaskAttachment");
  244. migrationBuilder.DropTable(
  245. name: "ProjectStageAttachment");
  246. migrationBuilder.DropTable(
  247. name: "ContractTask");
  248. migrationBuilder.DropTable(
  249. name: "ProjectStage");
  250. migrationBuilder.DropTable(
  251. name: "Contracts");
  252. }
  253. }
  254. }