20260209161454_PostMemberIdNullable.cs 2.0 KB

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