20250224080933_altrOrderRequest3.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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 altrOrderRequest3 : Migration
  9. {
  10. /// <inheritdoc />
  11. protected override void Up(MigrationBuilder migrationBuilder)
  12. {
  13. migrationBuilder.DropColumn(
  14. name: "CityId",
  15. table: "OrderRequests");
  16. migrationBuilder.DropColumn(
  17. name: "CountryId",
  18. table: "OrderRequests");
  19. migrationBuilder.AddColumn<long>(
  20. name: "BusinessTripExpensesId",
  21. table: "OrderRequests",
  22. type: "bigint",
  23. nullable: true);
  24. migrationBuilder.CreateTable(
  25. name: "OrderAttachment",
  26. columns: table => new
  27. {
  28. Id = table.Column<long>(type: "bigint", nullable: false)
  29. .Annotation("SqlServer:Identity", "1, 1"),
  30. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  31. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  32. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  33. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  34. OrderRequestId = table.Column<long>(type: "bigint", nullable: false),
  35. AttachmentTypeId = table.Column<long>(type: "bigint", nullable: true),
  36. FileName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: true),
  37. OriginalName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: true),
  38. FilePath = table.Column<string>(type: "nvarchar(max)", nullable: true),
  39. ContentType = table.Column<string>(type: "nvarchar(max)", nullable: true)
  40. },
  41. constraints: table =>
  42. {
  43. table.PrimaryKey("PK_OrderAttachment", x => x.Id);
  44. table.ForeignKey(
  45. name: "FK_OrderAttachment_OrderRequests_OrderRequestId",
  46. column: x => x.OrderRequestId,
  47. principalTable: "OrderRequests",
  48. principalColumn: "Id",
  49. onDelete: ReferentialAction.Cascade);
  50. });
  51. migrationBuilder.CreateTable(
  52. name: "OverTimeDay",
  53. columns: table => new
  54. {
  55. Id = table.Column<long>(type: "bigint", nullable: false)
  56. .Annotation("SqlServer:Identity", "1, 1"),
  57. OverTimeDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  58. StartTime = table.Column<string>(type: "nvarchar(max)", nullable: true),
  59. EndTime = table.Column<string>(type: "nvarchar(max)", nullable: true),
  60. TotalHours = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
  61. OrderRequestId = table.Column<long>(type: "bigint", nullable: true)
  62. },
  63. constraints: table =>
  64. {
  65. table.PrimaryKey("PK_OverTimeDay", x => x.Id);
  66. table.ForeignKey(
  67. name: "FK_OverTimeDay_OrderRequests_OrderRequestId",
  68. column: x => x.OrderRequestId,
  69. principalTable: "OrderRequests",
  70. principalColumn: "Id");
  71. });
  72. migrationBuilder.CreateTable(
  73. name: "BusinessTripExpenses",
  74. columns: table => new
  75. {
  76. Id = table.Column<long>(type: "bigint", nullable: false)
  77. .Annotation("SqlServer:Identity", "1, 1"),
  78. TicketCost = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
  79. TransportationCost = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
  80. AccommodationCost = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
  81. OtherCost = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
  82. TicketAttachmentId = table.Column<long>(type: "bigint", nullable: true),
  83. TransportationAttachmentId = table.Column<long>(type: "bigint", nullable: true),
  84. AccommodationAttachmentId = table.Column<long>(type: "bigint", nullable: true),
  85. OtherAttachmentId = table.Column<long>(type: "bigint", nullable: true)
  86. },
  87. constraints: table =>
  88. {
  89. table.PrimaryKey("PK_BusinessTripExpenses", x => x.Id);
  90. table.ForeignKey(
  91. name: "FK_BusinessTripExpenses_OrderAttachment_AccommodationAttachmentId",
  92. column: x => x.AccommodationAttachmentId,
  93. principalTable: "OrderAttachment",
  94. principalColumn: "Id");
  95. table.ForeignKey(
  96. name: "FK_BusinessTripExpenses_OrderAttachment_OtherAttachmentId",
  97. column: x => x.OtherAttachmentId,
  98. principalTable: "OrderAttachment",
  99. principalColumn: "Id");
  100. table.ForeignKey(
  101. name: "FK_BusinessTripExpenses_OrderAttachment_TicketAttachmentId",
  102. column: x => x.TicketAttachmentId,
  103. principalTable: "OrderAttachment",
  104. principalColumn: "Id");
  105. table.ForeignKey(
  106. name: "FK_BusinessTripExpenses_OrderAttachment_TransportationAttachmentId",
  107. column: x => x.TransportationAttachmentId,
  108. principalTable: "OrderAttachment",
  109. principalColumn: "Id");
  110. });
  111. migrationBuilder.InsertData(
  112. table: "AttachmentTypes",
  113. columns: new[] { "Id", "IsRequired", "NameAr", "NameEn" },
  114. values: new object[,]
  115. {
  116. { 10L, false, "تكلفة التذكرة", "Ticket Cost" },
  117. { 11L, false, "تكلفة المواصلات", "Transportation Cost" },
  118. { 12L, false, "تكلفة الاقامة", "Accommodation Cost" },
  119. { 13L, false, "اخرى", "Other" }
  120. });
  121. migrationBuilder.CreateIndex(
  122. name: "IX_OrderRequests_BusinessTripExpensesId",
  123. table: "OrderRequests",
  124. column: "BusinessTripExpensesId");
  125. migrationBuilder.CreateIndex(
  126. name: "IX_BusinessTripExpenses_AccommodationAttachmentId",
  127. table: "BusinessTripExpenses",
  128. column: "AccommodationAttachmentId");
  129. migrationBuilder.CreateIndex(
  130. name: "IX_BusinessTripExpenses_OtherAttachmentId",
  131. table: "BusinessTripExpenses",
  132. column: "OtherAttachmentId");
  133. migrationBuilder.CreateIndex(
  134. name: "IX_BusinessTripExpenses_TicketAttachmentId",
  135. table: "BusinessTripExpenses",
  136. column: "TicketAttachmentId");
  137. migrationBuilder.CreateIndex(
  138. name: "IX_BusinessTripExpenses_TransportationAttachmentId",
  139. table: "BusinessTripExpenses",
  140. column: "TransportationAttachmentId");
  141. migrationBuilder.CreateIndex(
  142. name: "IX_OrderAttachment_OrderRequestId",
  143. table: "OrderAttachment",
  144. column: "OrderRequestId");
  145. migrationBuilder.CreateIndex(
  146. name: "IX_OverTimeDay_OrderRequestId",
  147. table: "OverTimeDay",
  148. column: "OrderRequestId");
  149. migrationBuilder.AddForeignKey(
  150. name: "FK_OrderRequests_BusinessTripExpenses_BusinessTripExpensesId",
  151. table: "OrderRequests",
  152. column: "BusinessTripExpensesId",
  153. principalTable: "BusinessTripExpenses",
  154. principalColumn: "Id");
  155. }
  156. /// <inheritdoc />
  157. protected override void Down(MigrationBuilder migrationBuilder)
  158. {
  159. migrationBuilder.DropForeignKey(
  160. name: "FK_OrderRequests_BusinessTripExpenses_BusinessTripExpensesId",
  161. table: "OrderRequests");
  162. migrationBuilder.DropTable(
  163. name: "BusinessTripExpenses");
  164. migrationBuilder.DropTable(
  165. name: "OverTimeDay");
  166. migrationBuilder.DropTable(
  167. name: "OrderAttachment");
  168. migrationBuilder.DropIndex(
  169. name: "IX_OrderRequests_BusinessTripExpensesId",
  170. table: "OrderRequests");
  171. migrationBuilder.DeleteData(
  172. table: "AttachmentTypes",
  173. keyColumn: "Id",
  174. keyValue: 10L);
  175. migrationBuilder.DeleteData(
  176. table: "AttachmentTypes",
  177. keyColumn: "Id",
  178. keyValue: 11L);
  179. migrationBuilder.DeleteData(
  180. table: "AttachmentTypes",
  181. keyColumn: "Id",
  182. keyValue: 12L);
  183. migrationBuilder.DeleteData(
  184. table: "AttachmentTypes",
  185. keyColumn: "Id",
  186. keyValue: 13L);
  187. migrationBuilder.DropColumn(
  188. name: "BusinessTripExpensesId",
  189. table: "OrderRequests");
  190. migrationBuilder.AddColumn<int>(
  191. name: "CityId",
  192. table: "OrderRequests",
  193. type: "int",
  194. nullable: true);
  195. migrationBuilder.AddColumn<int>(
  196. name: "CountryId",
  197. table: "OrderRequests",
  198. type: "int",
  199. nullable: true);
  200. }
  201. }
  202. }