20240221104859_updateUser.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
  5. namespace MTWorkHR.Identity.Migrations
  6. {
  7. /// <inheritdoc />
  8. public partial class updateUser : Migration
  9. {
  10. /// <inheritdoc />
  11. protected override void Up(MigrationBuilder migrationBuilder)
  12. {
  13. migrationBuilder.AddColumn<string>(
  14. name: "FavoriteName",
  15. table: "AspNetUsers",
  16. type: "nvarchar(max)",
  17. nullable: true);
  18. migrationBuilder.AddColumn<decimal>(
  19. name: "IncomeTaxValue",
  20. table: "AspNetUsers",
  21. type: "decimal(18,2)",
  22. nullable: true);
  23. migrationBuilder.AddColumn<string>(
  24. name: "JobTitle",
  25. table: "AspNetUsers",
  26. type: "nvarchar(max)",
  27. nullable: true);
  28. migrationBuilder.AddColumn<string>(
  29. name: "PassportNumber",
  30. table: "AspNetUsers",
  31. type: "nvarchar(max)",
  32. nullable: false,
  33. defaultValue: "");
  34. migrationBuilder.AddColumn<int>(
  35. name: "QualificationId",
  36. table: "AspNetUsers",
  37. type: "int",
  38. nullable: true);
  39. migrationBuilder.AddColumn<decimal>(
  40. name: "TaxNumber",
  41. table: "AspNetUsers",
  42. type: "decimal(18,2)",
  43. nullable: true);
  44. migrationBuilder.AddColumn<string>(
  45. name: "University",
  46. table: "AspNetUsers",
  47. type: "nvarchar(max)",
  48. nullable: true);
  49. migrationBuilder.CreateTable(
  50. name: "AttachmentTypes",
  51. columns: table => new
  52. {
  53. Id = table.Column<long>(type: "bigint", nullable: false)
  54. .Annotation("SqlServer:Identity", "1, 1"),
  55. NameAr = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  56. NameEn = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  57. IsRequired = table.Column<bool>(type: "bit", nullable: false)
  58. },
  59. constraints: table =>
  60. {
  61. table.PrimaryKey("PK_AttachmentTypes", x => x.Id);
  62. });
  63. migrationBuilder.CreateTable(
  64. name: "UserAddress",
  65. columns: table => new
  66. {
  67. Id = table.Column<long>(type: "bigint", nullable: false)
  68. .Annotation("SqlServer:Identity", "1, 1"),
  69. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  70. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  71. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  72. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  73. UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
  74. CountryId = table.Column<int>(type: "int", nullable: false),
  75. City = table.Column<string>(type: "nvarchar(max)", nullable: false),
  76. PostalCode = table.Column<string>(type: "nvarchar(max)", nullable: false),
  77. AddressDesc = table.Column<string>(type: "nvarchar(max)", nullable: false)
  78. },
  79. constraints: table =>
  80. {
  81. table.PrimaryKey("PK_UserAddress", x => x.Id);
  82. table.ForeignKey(
  83. name: "FK_UserAddress_AspNetUsers_UserId",
  84. column: x => x.UserId,
  85. principalTable: "AspNetUsers",
  86. principalColumn: "Id",
  87. onDelete: ReferentialAction.Cascade);
  88. });
  89. migrationBuilder.CreateTable(
  90. name: "UserAttachments",
  91. columns: table => new
  92. {
  93. Id = table.Column<long>(type: "bigint", nullable: false)
  94. .Annotation("SqlServer:Identity", "1, 1"),
  95. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  96. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  97. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  98. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  99. UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
  100. AttachmentTypeId = table.Column<long>(type: "bigint", nullable: false),
  101. FileName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  102. OriginalName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false)
  103. },
  104. constraints: table =>
  105. {
  106. table.PrimaryKey("PK_UserAttachments", x => x.Id);
  107. table.ForeignKey(
  108. name: "FK_UserAttachments_AspNetUsers_UserId",
  109. column: x => x.UserId,
  110. principalTable: "AspNetUsers",
  111. principalColumn: "Id",
  112. onDelete: ReferentialAction.Cascade);
  113. table.ForeignKey(
  114. name: "FK_UserAttachments_AttachmentTypes_AttachmentTypeId",
  115. column: x => x.AttachmentTypeId,
  116. principalTable: "AttachmentTypes",
  117. principalColumn: "Id",
  118. onDelete: ReferentialAction.Cascade);
  119. });
  120. migrationBuilder.UpdateData(
  121. table: "AspNetUsers",
  122. keyColumn: "Id",
  123. keyValue: "ADMB3B92-2311-48F8-9DEC-F9FAEF1F21UA",
  124. columns: new[] { "FavoriteName", "IncomeTaxValue", "JobTitle", "PassportNumber", "QualificationId", "TaxNumber", "University" },
  125. values: new object[] { null, 1m, null, "1234567", 1, 111m, null });
  126. migrationBuilder.UpdateData(
  127. table: "AspNetUsers",
  128. keyColumn: "Id",
  129. keyValue: "AL5B3B92-2311-48F8-9DEC-F9FAEF1F21UB",
  130. columns: new[] { "FavoriteName", "IncomeTaxValue", "JobTitle", "PassportNumber", "QualificationId", "TaxNumber", "University" },
  131. values: new object[] { null, 100m, null, "7654321001010", 1, 222m, null });
  132. migrationBuilder.InsertData(
  133. table: "AttachmentTypes",
  134. columns: new[] { "Id", "IsRequired", "NameAr", "NameEn" },
  135. values: new object[,]
  136. {
  137. { 1L, false, "السيرة الذاتية", "CV" },
  138. { 2L, false, "الهوية", "Identification" }
  139. });
  140. migrationBuilder.CreateIndex(
  141. name: "IX_UserAddress_UserId",
  142. table: "UserAddress",
  143. column: "UserId",
  144. unique: true);
  145. migrationBuilder.CreateIndex(
  146. name: "IX_UserAttachments_AttachmentTypeId",
  147. table: "UserAttachments",
  148. column: "AttachmentTypeId");
  149. migrationBuilder.CreateIndex(
  150. name: "IX_UserAttachments_UserId",
  151. table: "UserAttachments",
  152. column: "UserId");
  153. }
  154. /// <inheritdoc />
  155. protected override void Down(MigrationBuilder migrationBuilder)
  156. {
  157. migrationBuilder.DropTable(
  158. name: "UserAddress");
  159. migrationBuilder.DropTable(
  160. name: "UserAttachments");
  161. migrationBuilder.DropTable(
  162. name: "AttachmentTypes");
  163. migrationBuilder.DropColumn(
  164. name: "FavoriteName",
  165. table: "AspNetUsers");
  166. migrationBuilder.DropColumn(
  167. name: "IncomeTaxValue",
  168. table: "AspNetUsers");
  169. migrationBuilder.DropColumn(
  170. name: "JobTitle",
  171. table: "AspNetUsers");
  172. migrationBuilder.DropColumn(
  173. name: "PassportNumber",
  174. table: "AspNetUsers");
  175. migrationBuilder.DropColumn(
  176. name: "QualificationId",
  177. table: "AspNetUsers");
  178. migrationBuilder.DropColumn(
  179. name: "TaxNumber",
  180. table: "AspNetUsers");
  181. migrationBuilder.DropColumn(
  182. name: "University",
  183. table: "AspNetUsers");
  184. }
  185. }
  186. }