20240131193715_updateUserAddress.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace MTWorkHR.Identity.Migrations
  5. {
  6. /// <inheritdoc />
  7. public partial class updateUserAddress : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.CreateTable(
  13. name: "UserAddress",
  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. UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
  23. CountryId = table.Column<int>(type: "int", nullable: false),
  24. City = table.Column<string>(type: "nvarchar(max)", nullable: false),
  25. PostalCode = table.Column<string>(type: "nvarchar(max)", nullable: false),
  26. AddressDesc = table.Column<string>(type: "nvarchar(max)", nullable: false)
  27. },
  28. constraints: table =>
  29. {
  30. table.PrimaryKey("PK_UserAddress", x => x.Id);
  31. table.ForeignKey(
  32. name: "FK_UserAddress_AspNetUsers_UserId",
  33. column: x => x.UserId,
  34. principalTable: "AspNetUsers",
  35. principalColumn: "Id",
  36. onDelete: ReferentialAction.Cascade);
  37. });
  38. migrationBuilder.CreateIndex(
  39. name: "IX_UserAddress_UserId",
  40. table: "UserAddress",
  41. column: "UserId",
  42. unique: true);
  43. }
  44. /// <inheritdoc />
  45. protected override void Down(MigrationBuilder migrationBuilder)
  46. {
  47. migrationBuilder.DropTable(
  48. name: "UserAddress");
  49. }
  50. }
  51. }