20260209161454_PostMemberIdNullable.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using Microsoft.EntityFrameworkCore.Migrations;
  2. #nullable disable
  3. namespace Infrastructure.Migrations.AppDb;
  4. /// <inheritdoc />
  5. public partial class PostMemberIdNullable : Migration
  6. {
  7. /// <inheritdoc />
  8. protected override void Up(MigrationBuilder migrationBuilder)
  9. {
  10. migrationBuilder.DropForeignKey(
  11. name: "FK_Post_Member_MemberID",
  12. table: "Post");
  13. migrationBuilder.AlterColumn<int>(
  14. name: "MemberID",
  15. table: "Post",
  16. type: "int",
  17. nullable: true,
  18. comment: "회원 ID",
  19. oldClrType: typeof(int),
  20. oldType: "int",
  21. oldComment: "회원 ID");
  22. migrationBuilder.AddForeignKey(
  23. name: "FK_Post_Member_MemberID",
  24. table: "Post",
  25. column: "MemberID",
  26. principalTable: "Member",
  27. principalColumn: "ID",
  28. onDelete: ReferentialAction.SetNull);
  29. }
  30. /// <inheritdoc />
  31. protected override void Down(MigrationBuilder migrationBuilder)
  32. {
  33. migrationBuilder.DropForeignKey(
  34. name: "FK_Post_Member_MemberID",
  35. table: "Post");
  36. migrationBuilder.AlterColumn<int>(
  37. name: "MemberID",
  38. table: "Post",
  39. type: "int",
  40. nullable: false,
  41. defaultValue: 0,
  42. comment: "회원 ID",
  43. oldClrType: typeof(int),
  44. oldType: "int",
  45. oldNullable: true,
  46. oldComment: "회원 ID");
  47. migrationBuilder.AddForeignKey(
  48. name: "FK_Post_Member_MemberID",
  49. table: "Post",
  50. column: "MemberID",
  51. principalTable: "Member",
  52. principalColumn: "ID",
  53. onDelete: ReferentialAction.Restrict);
  54. }
  55. }