20240131192843_updateUser.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace MTWorkHR.Identity.Migrations
  5. {
  6. /// <inheritdoc />
  7. public partial class updateUser : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.AddColumn<string>(
  13. name: "FavoriteName",
  14. table: "AspNetUsers",
  15. type: "nvarchar(max)",
  16. nullable: true);
  17. migrationBuilder.AddColumn<decimal>(
  18. name: "IncomeTaxValue",
  19. table: "AspNetUsers",
  20. type: "decimal(18,2)",
  21. nullable: false,
  22. defaultValue: 0m);
  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: false,
  39. defaultValue: 0);
  40. migrationBuilder.AddColumn<decimal>(
  41. name: "TaxNumber",
  42. table: "AspNetUsers",
  43. type: "decimal(18,2)",
  44. nullable: false,
  45. defaultValue: 0m);
  46. migrationBuilder.AddColumn<string>(
  47. name: "University",
  48. table: "AspNetUsers",
  49. type: "nvarchar(max)",
  50. nullable: true);
  51. migrationBuilder.CreateTable(
  52. name: "AttachmentType",
  53. columns: table => new
  54. {
  55. Id = table.Column<long>(type: "bigint", nullable: false)
  56. .Annotation("SqlServer:Identity", "1, 1"),
  57. NameAr = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  58. NameEn = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  59. IsRequired = table.Column<bool>(type: "bit", nullable: false)
  60. },
  61. constraints: table =>
  62. {
  63. table.PrimaryKey("PK_AttachmentType", x => x.Id);
  64. });
  65. migrationBuilder.CreateTable(
  66. name: "UserAttachment",
  67. columns: table => new
  68. {
  69. Id = table.Column<long>(type: "bigint", nullable: false)
  70. .Annotation("SqlServer:Identity", "1, 1"),
  71. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  72. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  73. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  74. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  75. UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
  76. AttachmentTypeId = table.Column<long>(type: "bigint", nullable: false),
  77. FileName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
  78. OriginalName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false)
  79. },
  80. constraints: table =>
  81. {
  82. table.PrimaryKey("PK_UserAttachment", x => x.Id);
  83. table.ForeignKey(
  84. name: "FK_UserAttachment_AspNetUsers_UserId",
  85. column: x => x.UserId,
  86. principalTable: "AspNetUsers",
  87. principalColumn: "Id",
  88. onDelete: ReferentialAction.Cascade);
  89. table.ForeignKey(
  90. name: "FK_UserAttachment_AttachmentType_AttachmentTypeId",
  91. column: x => x.AttachmentTypeId,
  92. principalTable: "AttachmentType",
  93. principalColumn: "Id",
  94. onDelete: ReferentialAction.Cascade);
  95. });
  96. migrationBuilder.UpdateData(
  97. table: "AspNetUsers",
  98. keyColumn: "Id",
  99. keyValue: "ADMB3B92-2311-48F8-9DEC-F9FAEF1F21UA",
  100. columns: new[] { "FavoriteName", "IncomeTaxValue", "JobTitle", "PassportNumber", "QualificationId", "TaxNumber", "University" },
  101. values: new object[] { null, 0m, null, "1234567", 0, 0m, null });
  102. migrationBuilder.UpdateData(
  103. table: "AspNetUsers",
  104. keyColumn: "Id",
  105. keyValue: "AL5B3B92-2311-48F8-9DEC-F9FAEF1F21UB",
  106. columns: new[] { "FavoriteName", "IncomeTaxValue", "JobTitle", "PassportNumber", "QualificationId", "TaxNumber", "University" },
  107. values: new object[] { null, 0m, null, "7654321001010", 0, 0m, null });
  108. migrationBuilder.CreateIndex(
  109. name: "IX_UserAttachment_AttachmentTypeId",
  110. table: "UserAttachment",
  111. column: "AttachmentTypeId");
  112. migrationBuilder.CreateIndex(
  113. name: "IX_UserAttachment_UserId",
  114. table: "UserAttachment",
  115. column: "UserId");
  116. }
  117. /// <inheritdoc />
  118. protected override void Down(MigrationBuilder migrationBuilder)
  119. {
  120. migrationBuilder.DropTable(
  121. name: "UserAttachment");
  122. migrationBuilder.DropTable(
  123. name: "AttachmentType");
  124. migrationBuilder.DropColumn(
  125. name: "FavoriteName",
  126. table: "AspNetUsers");
  127. migrationBuilder.DropColumn(
  128. name: "IncomeTaxValue",
  129. table: "AspNetUsers");
  130. migrationBuilder.DropColumn(
  131. name: "JobTitle",
  132. table: "AspNetUsers");
  133. migrationBuilder.DropColumn(
  134. name: "PassportNumber",
  135. table: "AspNetUsers");
  136. migrationBuilder.DropColumn(
  137. name: "QualificationId",
  138. table: "AspNetUsers");
  139. migrationBuilder.DropColumn(
  140. name: "TaxNumber",
  141. table: "AspNetUsers");
  142. migrationBuilder.DropColumn(
  143. name: "University",
  144. table: "AspNetUsers");
  145. }
  146. }
  147. }