20260706030326_AddPostCheer.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Infrastructure.Migrations.AppDb
  5. {
  6. /// <inheritdoc />
  7. public partial class AddPostCheer : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.AddColumn<int>(
  13. name: "Reward_CheerDailyMax",
  14. table: "Config",
  15. type: "int",
  16. nullable: false,
  17. defaultValue: 0);
  18. migrationBuilder.AddColumn<int>(
  19. name: "Reward_CheerFeePercent",
  20. table: "Config",
  21. type: "int",
  22. nullable: false,
  23. defaultValue: 0);
  24. migrationBuilder.AddColumn<int>(
  25. name: "Reward_CheerMinAmount",
  26. table: "Config",
  27. type: "int",
  28. nullable: false,
  29. defaultValue: 0);
  30. migrationBuilder.CreateTable(
  31. name: "PostCheer",
  32. columns: table => new
  33. {
  34. ID = table.Column<int>(type: "int", nullable: false, comment: "PK")
  35. .Annotation("SqlServer:Identity", "1, 1"),
  36. PostID = table.Column<int>(type: "int", nullable: false, comment: "응원 대상 게시글 ID"),
  37. FromMemberID = table.Column<int>(type: "int", nullable: false, comment: "응원 발신자 회원 ID"),
  38. ToMemberID = table.Column<int>(type: "int", nullable: false, comment: "응원 수신자(글 작성자) 회원 ID"),
  39. Amount = table.Column<int>(type: "int", nullable: false, comment: "총 응원 금액"),
  40. FeeAmount = table.Column<int>(type: "int", nullable: false, comment: "플랫폼 수수료(소각분)"),
  41. NetAmount = table.Column<int>(type: "int", nullable: false, comment: "작성자 수령 순액(Reward 적립)"),
  42. Message = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "응원 한마디"),
  43. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "응원 일시")
  44. },
  45. constraints: table =>
  46. {
  47. table.PrimaryKey("PK_PostCheer", x => x.ID);
  48. table.ForeignKey(
  49. name: "FK_PostCheer_Member_FromMemberID",
  50. column: x => x.FromMemberID,
  51. principalTable: "Member",
  52. principalColumn: "ID");
  53. table.ForeignKey(
  54. name: "FK_PostCheer_Member_ToMemberID",
  55. column: x => x.ToMemberID,
  56. principalTable: "Member",
  57. principalColumn: "ID");
  58. table.ForeignKey(
  59. name: "FK_PostCheer_Post_PostID",
  60. column: x => x.PostID,
  61. principalTable: "Post",
  62. principalColumn: "ID");
  63. },
  64. comment: "분석글 응원(Cheer) — D3 M4");
  65. migrationBuilder.CreateIndex(
  66. name: "IX_PostCheer_FromMemberID_CreatedAt",
  67. table: "PostCheer",
  68. columns: new[] { "FromMemberID", "CreatedAt" });
  69. migrationBuilder.CreateIndex(
  70. name: "IX_PostCheer_PostID",
  71. table: "PostCheer",
  72. column: "PostID");
  73. migrationBuilder.CreateIndex(
  74. name: "IX_PostCheer_ToMemberID_CreatedAt",
  75. table: "PostCheer",
  76. columns: new[] { "ToMemberID", "CreatedAt" });
  77. }
  78. /// <inheritdoc />
  79. protected override void Down(MigrationBuilder migrationBuilder)
  80. {
  81. migrationBuilder.DropTable(
  82. name: "PostCheer");
  83. migrationBuilder.DropColumn(
  84. name: "Reward_CheerDailyMax",
  85. table: "Config");
  86. migrationBuilder.DropColumn(
  87. name: "Reward_CheerFeePercent",
  88. table: "Config");
  89. migrationBuilder.DropColumn(
  90. name: "Reward_CheerMinAmount",
  91. table: "Config");
  92. }
  93. }
  94. }