20250306115344_altrOrderRequestAttach.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace MTWorkHR.Infrastructure.Migrations
  5. {
  6. /// <inheritdoc />
  7. public partial class altrOrderRequestAttach : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.DropForeignKey(
  13. name: "FK_BusinessTripExpenses_OrderAttachment_AccommodationAttachmentId",
  14. table: "BusinessTripExpenses");
  15. migrationBuilder.DropForeignKey(
  16. name: "FK_BusinessTripExpenses_OrderAttachment_OtherAttachmentId",
  17. table: "BusinessTripExpenses");
  18. migrationBuilder.DropForeignKey(
  19. name: "FK_BusinessTripExpenses_OrderAttachment_TicketAttachmentId",
  20. table: "BusinessTripExpenses");
  21. migrationBuilder.DropForeignKey(
  22. name: "FK_BusinessTripExpenses_OrderAttachment_TransportationAttachmentId",
  23. table: "BusinessTripExpenses");
  24. migrationBuilder.DropForeignKey(
  25. name: "FK_OverTimeDay_OrderAttachment_OverTimeAttachmentId",
  26. table: "OverTimeDay");
  27. migrationBuilder.DropIndex(
  28. name: "IX_OverTimeDay_OverTimeAttachmentId",
  29. table: "OverTimeDay");
  30. migrationBuilder.DropIndex(
  31. name: "IX_BusinessTripExpenses_AccommodationAttachmentId",
  32. table: "BusinessTripExpenses");
  33. migrationBuilder.DropIndex(
  34. name: "IX_BusinessTripExpenses_OtherAttachmentId",
  35. table: "BusinessTripExpenses");
  36. migrationBuilder.DropIndex(
  37. name: "IX_BusinessTripExpenses_TicketAttachmentId",
  38. table: "BusinessTripExpenses");
  39. migrationBuilder.DropIndex(
  40. name: "IX_BusinessTripExpenses_TransportationAttachmentId",
  41. table: "BusinessTripExpenses");
  42. migrationBuilder.DropColumn(
  43. name: "OverTimeAttachmentId",
  44. table: "OverTimeDay");
  45. migrationBuilder.DropColumn(
  46. name: "AccommodationAttachmentId",
  47. table: "BusinessTripExpenses");
  48. migrationBuilder.DropColumn(
  49. name: "OtherAttachmentId",
  50. table: "BusinessTripExpenses");
  51. migrationBuilder.DropColumn(
  52. name: "TicketAttachmentId",
  53. table: "BusinessTripExpenses");
  54. migrationBuilder.DropColumn(
  55. name: "TransportationAttachmentId",
  56. table: "BusinessTripExpenses");
  57. migrationBuilder.CreateTable(
  58. name: "BusinessTripAttachment",
  59. columns: table => new
  60. {
  61. Id = table.Column<long>(type: "bigint", nullable: false)
  62. .Annotation("SqlServer:Identity", "1, 1"),
  63. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  64. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  65. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  66. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  67. BusinessTripExpensesId = table.Column<long>(type: "bigint", nullable: false),
  68. FileName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: true),
  69. OriginalName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: true),
  70. FilePath = table.Column<string>(type: "nvarchar(max)", nullable: true),
  71. ContentType = table.Column<string>(type: "nvarchar(max)", nullable: true)
  72. },
  73. constraints: table =>
  74. {
  75. table.PrimaryKey("PK_BusinessTripAttachment", x => x.Id);
  76. table.ForeignKey(
  77. name: "FK_BusinessTripAttachment_BusinessTripExpenses_BusinessTripExpensesId",
  78. column: x => x.BusinessTripExpensesId,
  79. principalTable: "BusinessTripExpenses",
  80. principalColumn: "Id",
  81. onDelete: ReferentialAction.Cascade);
  82. });
  83. migrationBuilder.CreateTable(
  84. name: "OverTimeDayAttachment",
  85. columns: table => new
  86. {
  87. Id = table.Column<long>(type: "bigint", nullable: false)
  88. .Annotation("SqlServer:Identity", "1, 1"),
  89. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  90. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  91. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  92. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  93. OverTimeDayId = table.Column<long>(type: "bigint", nullable: false),
  94. FileName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: true),
  95. OriginalName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: true),
  96. FilePath = table.Column<string>(type: "nvarchar(max)", nullable: true),
  97. ContentType = table.Column<string>(type: "nvarchar(max)", nullable: true)
  98. },
  99. constraints: table =>
  100. {
  101. table.PrimaryKey("PK_OverTimeDayAttachment", x => x.Id);
  102. table.ForeignKey(
  103. name: "FK_OverTimeDayAttachment_OverTimeDay_OverTimeDayId",
  104. column: x => x.OverTimeDayId,
  105. principalTable: "OverTimeDay",
  106. principalColumn: "Id",
  107. onDelete: ReferentialAction.Cascade);
  108. });
  109. migrationBuilder.CreateIndex(
  110. name: "IX_BusinessTripAttachment_BusinessTripExpensesId",
  111. table: "BusinessTripAttachment",
  112. column: "BusinessTripExpensesId");
  113. migrationBuilder.CreateIndex(
  114. name: "IX_OverTimeDayAttachment_OverTimeDayId",
  115. table: "OverTimeDayAttachment",
  116. column: "OverTimeDayId",
  117. unique: true);
  118. }
  119. /// <inheritdoc />
  120. protected override void Down(MigrationBuilder migrationBuilder)
  121. {
  122. migrationBuilder.DropTable(
  123. name: "BusinessTripAttachment");
  124. migrationBuilder.DropTable(
  125. name: "OverTimeDayAttachment");
  126. migrationBuilder.AddColumn<long>(
  127. name: "OverTimeAttachmentId",
  128. table: "OverTimeDay",
  129. type: "bigint",
  130. nullable: true);
  131. migrationBuilder.AddColumn<long>(
  132. name: "AccommodationAttachmentId",
  133. table: "BusinessTripExpenses",
  134. type: "bigint",
  135. nullable: true);
  136. migrationBuilder.AddColumn<long>(
  137. name: "OtherAttachmentId",
  138. table: "BusinessTripExpenses",
  139. type: "bigint",
  140. nullable: true);
  141. migrationBuilder.AddColumn<long>(
  142. name: "TicketAttachmentId",
  143. table: "BusinessTripExpenses",
  144. type: "bigint",
  145. nullable: true);
  146. migrationBuilder.AddColumn<long>(
  147. name: "TransportationAttachmentId",
  148. table: "BusinessTripExpenses",
  149. type: "bigint",
  150. nullable: true);
  151. migrationBuilder.CreateIndex(
  152. name: "IX_OverTimeDay_OverTimeAttachmentId",
  153. table: "OverTimeDay",
  154. column: "OverTimeAttachmentId");
  155. migrationBuilder.CreateIndex(
  156. name: "IX_BusinessTripExpenses_AccommodationAttachmentId",
  157. table: "BusinessTripExpenses",
  158. column: "AccommodationAttachmentId");
  159. migrationBuilder.CreateIndex(
  160. name: "IX_BusinessTripExpenses_OtherAttachmentId",
  161. table: "BusinessTripExpenses",
  162. column: "OtherAttachmentId");
  163. migrationBuilder.CreateIndex(
  164. name: "IX_BusinessTripExpenses_TicketAttachmentId",
  165. table: "BusinessTripExpenses",
  166. column: "TicketAttachmentId");
  167. migrationBuilder.CreateIndex(
  168. name: "IX_BusinessTripExpenses_TransportationAttachmentId",
  169. table: "BusinessTripExpenses",
  170. column: "TransportationAttachmentId");
  171. migrationBuilder.AddForeignKey(
  172. name: "FK_BusinessTripExpenses_OrderAttachment_AccommodationAttachmentId",
  173. table: "BusinessTripExpenses",
  174. column: "AccommodationAttachmentId",
  175. principalTable: "OrderAttachment",
  176. principalColumn: "Id");
  177. migrationBuilder.AddForeignKey(
  178. name: "FK_BusinessTripExpenses_OrderAttachment_OtherAttachmentId",
  179. table: "BusinessTripExpenses",
  180. column: "OtherAttachmentId",
  181. principalTable: "OrderAttachment",
  182. principalColumn: "Id");
  183. migrationBuilder.AddForeignKey(
  184. name: "FK_BusinessTripExpenses_OrderAttachment_TicketAttachmentId",
  185. table: "BusinessTripExpenses",
  186. column: "TicketAttachmentId",
  187. principalTable: "OrderAttachment",
  188. principalColumn: "Id");
  189. migrationBuilder.AddForeignKey(
  190. name: "FK_BusinessTripExpenses_OrderAttachment_TransportationAttachmentId",
  191. table: "BusinessTripExpenses",
  192. column: "TransportationAttachmentId",
  193. principalTable: "OrderAttachment",
  194. principalColumn: "Id");
  195. migrationBuilder.AddForeignKey(
  196. name: "FK_OverTimeDay_OrderAttachment_OverTimeAttachmentId",
  197. table: "OverTimeDay",
  198. column: "OverTimeAttachmentId",
  199. principalTable: "OrderAttachment",
  200. principalColumn: "Id");
  201. }
  202. }
  203. }