20260724072054_AddRewardEngineAndAttendance.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Infrastructure.Migrations.AppDb
  5. {
  6. /// <inheritdoc />
  7. public partial class AddRewardEngineAndAttendance : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.AddColumn<int>(
  13. name: "Attendance_BaseExp",
  14. table: "Config",
  15. type: "int",
  16. nullable: false,
  17. defaultValue: 0,
  18. comment: "기본 경험치");
  19. migrationBuilder.AddColumn<int>(
  20. name: "Attendance_BasePoint",
  21. table: "Config",
  22. type: "int",
  23. nullable: false,
  24. defaultValue: 0,
  25. comment: "기본 포인트");
  26. migrationBuilder.AddColumn<bool>(
  27. name: "Attendance_IsEnabled",
  28. table: "Config",
  29. type: "bit",
  30. nullable: false,
  31. defaultValue: false,
  32. comment: "출석 기능 활성화");
  33. migrationBuilder.AddColumn<string>(
  34. name: "Attendance_RankBonusConfig",
  35. table: "Config",
  36. type: "nvarchar(2000)",
  37. maxLength: 2000,
  38. nullable: true,
  39. comment: "순위별 보상 설정 (JSON)");
  40. migrationBuilder.AddColumn<int>(
  41. name: "Attendance_StreakBonusMaxDays",
  42. table: "Config",
  43. type: "int",
  44. nullable: false,
  45. defaultValue: 0,
  46. comment: "가중치 최대 적용 일수");
  47. migrationBuilder.AddColumn<int>(
  48. name: "Attendance_StreakBonusPerDay",
  49. table: "Config",
  50. type: "int",
  51. nullable: false,
  52. defaultValue: 0,
  53. comment: "1일당 추가 경험치");
  54. migrationBuilder.AddColumn<int>(
  55. name: "Attendance_StreakBonusPointPerDay",
  56. table: "Config",
  57. type: "int",
  58. nullable: false,
  59. defaultValue: 0,
  60. comment: "1일당 추가 포인트");
  61. migrationBuilder.AddColumn<bool>(
  62. name: "Attendance_UseRankBonus",
  63. table: "Config",
  64. type: "bit",
  65. nullable: false,
  66. defaultValue: false,
  67. comment: "순위 보상 사용");
  68. migrationBuilder.AddColumn<bool>(
  69. name: "Attendance_UseStreakBonus",
  70. table: "Config",
  71. type: "bit",
  72. nullable: false,
  73. defaultValue: false,
  74. comment: "연속 출석 가중치 사용");
  75. migrationBuilder.AddColumn<int>(
  76. name: "Reward_CommentDailyCount",
  77. table: "Config",
  78. type: "int",
  79. nullable: false,
  80. defaultValue: 0,
  81. comment: "댓글 보상 일일 횟수 상한 (0=무제한)");
  82. migrationBuilder.AddColumn<int>(
  83. name: "Reward_CommentDailyExp",
  84. table: "Config",
  85. type: "int",
  86. nullable: false,
  87. defaultValue: 0,
  88. comment: "댓글 보상 일일 경험치 상한 (0=무제한)");
  89. migrationBuilder.AddColumn<int>(
  90. name: "Reward_CommentDailyPoint",
  91. table: "Config",
  92. type: "int",
  93. nullable: false,
  94. defaultValue: 0,
  95. comment: "댓글 보상 일일 토큰 상한 (0=무제한)");
  96. migrationBuilder.AddColumn<int>(
  97. name: "Reward_CommentExp",
  98. table: "Config",
  99. type: "int",
  100. nullable: false,
  101. defaultValue: 0,
  102. comment: "댓글 작성 지급 경험치");
  103. migrationBuilder.AddColumn<int>(
  104. name: "Reward_CommentPoint",
  105. table: "Config",
  106. type: "int",
  107. nullable: false,
  108. defaultValue: 0,
  109. comment: "댓글 작성 지급 토큰");
  110. migrationBuilder.AddColumn<int>(
  111. name: "Reward_LikeGivenDailyCount",
  112. table: "Config",
  113. type: "int",
  114. nullable: false,
  115. defaultValue: 0,
  116. comment: "추천(누른 쪽) 보상 일일 횟수 상한 (0=무제한)");
  117. migrationBuilder.AddColumn<int>(
  118. name: "Reward_LikeGivenDailyExp",
  119. table: "Config",
  120. type: "int",
  121. nullable: false,
  122. defaultValue: 0,
  123. comment: "추천(누른 쪽) 보상 일일 경험치 상한 (0=무제한)");
  124. migrationBuilder.AddColumn<int>(
  125. name: "Reward_LikeGivenExp",
  126. table: "Config",
  127. type: "int",
  128. nullable: false,
  129. defaultValue: 0,
  130. comment: "추천(누른 쪽) 지급 경험치");
  131. migrationBuilder.AddColumn<int>(
  132. name: "Reward_LikeReceivedDailyCount",
  133. table: "Config",
  134. type: "int",
  135. nullable: false,
  136. defaultValue: 0,
  137. comment: "추천(받은 쪽) 보상 일일 횟수 상한 (0=무제한)");
  138. migrationBuilder.AddColumn<int>(
  139. name: "Reward_LikeReceivedDailyPoint",
  140. table: "Config",
  141. type: "int",
  142. nullable: false,
  143. defaultValue: 0,
  144. comment: "추천(받은 쪽) 보상 일일 토큰 상한 (0=무제한)");
  145. migrationBuilder.AddColumn<int>(
  146. name: "Reward_LikeReceivedPoint",
  147. table: "Config",
  148. type: "int",
  149. nullable: false,
  150. defaultValue: 0,
  151. comment: "추천(받은 쪽) 지급 토큰");
  152. migrationBuilder.AddColumn<int>(
  153. name: "Reward_MinCommentLength",
  154. table: "Config",
  155. type: "int",
  156. nullable: false,
  157. defaultValue: 0,
  158. comment: "보상 지급 최소 댓글 길이 (0=제한 없음)");
  159. migrationBuilder.AddColumn<int>(
  160. name: "Reward_MinPostLength",
  161. table: "Config",
  162. type: "int",
  163. nullable: false,
  164. defaultValue: 0,
  165. comment: "보상 지급 최소 게시글 길이 (0=제한 없음)");
  166. migrationBuilder.AddColumn<int>(
  167. name: "Reward_NewMemberHoldDays",
  168. table: "Config",
  169. type: "int",
  170. nullable: false,
  171. defaultValue: 0,
  172. comment: "신규 회원 보상 유예 기간(일, 0=유예 없음)");
  173. migrationBuilder.AddColumn<int>(
  174. name: "Reward_PostDailyCount",
  175. table: "Config",
  176. type: "int",
  177. nullable: false,
  178. defaultValue: 0,
  179. comment: "게시글 보상 일일 횟수 상한 (0=무제한)");
  180. migrationBuilder.AddColumn<int>(
  181. name: "Reward_PostDailyExp",
  182. table: "Config",
  183. type: "int",
  184. nullable: false,
  185. defaultValue: 0,
  186. comment: "게시글 보상 일일 경험치 상한 (0=무제한)");
  187. migrationBuilder.AddColumn<int>(
  188. name: "Reward_PostDailyPoint",
  189. table: "Config",
  190. type: "int",
  191. nullable: false,
  192. defaultValue: 0,
  193. comment: "게시글 보상 일일 토큰 상한 (0=무제한)");
  194. migrationBuilder.AddColumn<int>(
  195. name: "Reward_PostExp",
  196. table: "Config",
  197. type: "int",
  198. nullable: false,
  199. defaultValue: 0,
  200. comment: "게시글 작성 지급 경험치");
  201. migrationBuilder.AddColumn<int>(
  202. name: "Reward_PostPoint",
  203. table: "Config",
  204. type: "int",
  205. nullable: false,
  206. defaultValue: 0,
  207. comment: "게시글 작성 지급 토큰");
  208. migrationBuilder.AddColumn<int>(
  209. name: "SignupReward_CashAmount",
  210. table: "Config",
  211. type: "int",
  212. nullable: false,
  213. defaultValue: 0,
  214. comment: "지급 캐시 (Adjusted)");
  215. migrationBuilder.AddColumn<int>(
  216. name: "SignupReward_CoinAmount",
  217. table: "Config",
  218. type: "int",
  219. nullable: false,
  220. defaultValue: 0,
  221. comment: "지급 코인 (Airdrop)");
  222. migrationBuilder.AddColumn<bool>(
  223. name: "SignupReward_Enabled",
  224. table: "Config",
  225. type: "bit",
  226. nullable: false,
  227. defaultValue: false,
  228. comment: "가입 축하 보상 활성화");
  229. migrationBuilder.AddColumn<int>(
  230. name: "SignupReward_ExpAmount",
  231. table: "Config",
  232. type: "int",
  233. nullable: false,
  234. defaultValue: 0,
  235. comment: "지급 경험치");
  236. migrationBuilder.CreateTable(
  237. name: "Attendance",
  238. columns: table => new
  239. {
  240. ID = table.Column<int>(type: "int", nullable: false)
  241. .Annotation("SqlServer:Identity", "1, 1"),
  242. MemberID = table.Column<int>(type: "int", nullable: false, comment: "회원 ID"),
  243. Greeting = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false, comment: "출석 인사"),
  244. ConsecutiveDays = table.Column<int>(type: "int", nullable: false, comment: "연속 출석 일수"),
  245. ExpRewarded = table.Column<int>(type: "int", nullable: false, comment: "지급 경험치"),
  246. PointRewarded = table.Column<int>(type: "int", nullable: false, comment: "지급 포인트"),
  247. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "출석 일시")
  248. },
  249. constraints: table =>
  250. {
  251. table.PrimaryKey("PK_Attendance", x => x.ID);
  252. table.ForeignKey(
  253. name: "FK_Attendance_Member_MemberID",
  254. column: x => x.MemberID,
  255. principalTable: "Member",
  256. principalColumn: "ID");
  257. },
  258. comment: "출석 기록");
  259. migrationBuilder.CreateTable(
  260. name: "MemberDailyRewardCounter",
  261. columns: table => new
  262. {
  263. MemberID = table.Column<int>(type: "int", nullable: false, comment: "회원 ID"),
  264. RewardDate = table.Column<DateOnly>(type: "date", nullable: false, comment: "KST 기준 일자"),
  265. ActionType = table.Column<byte>(type: "tinyint", nullable: false, comment: "액션 유형 (Post=1..PaperReward=8)"),
  266. Count = table.Column<int>(type: "int", nullable: false, comment: "오늘 지급 횟수"),
  267. ExpTotal = table.Column<int>(type: "int", nullable: false, comment: "오늘 지급 경험치 합계"),
  268. PointTotal = table.Column<int>(type: "int", nullable: false, comment: "오늘 지급 토큰 합계")
  269. },
  270. constraints: table =>
  271. {
  272. table.PrimaryKey("PK_MemberDailyRewardCounter", x => new { x.MemberID, x.RewardDate, x.ActionType });
  273. table.ForeignKey(
  274. name: "FK_MemberDailyRewardCounter_Member_MemberID",
  275. column: x => x.MemberID,
  276. principalTable: "Member",
  277. principalColumn: "ID",
  278. onDelete: ReferentialAction.Cascade);
  279. },
  280. comment: "일일 보상 캡 원장 (d3 M2)");
  281. migrationBuilder.CreateIndex(
  282. name: "IX_Attendance_CreatedAt",
  283. table: "Attendance",
  284. column: "CreatedAt",
  285. descending: new bool[0]);
  286. migrationBuilder.CreateIndex(
  287. name: "IX_Attendance_MemberID_CreatedAt",
  288. table: "Attendance",
  289. columns: new[] { "MemberID", "CreatedAt" },
  290. descending: new[] { false, true });
  291. migrationBuilder.CreateIndex(
  292. name: "IX_MemberDailyRewardCounter_RewardDate",
  293. table: "MemberDailyRewardCounter",
  294. column: "RewardDate");
  295. }
  296. /// <inheritdoc />
  297. protected override void Down(MigrationBuilder migrationBuilder)
  298. {
  299. migrationBuilder.DropTable(
  300. name: "Attendance");
  301. migrationBuilder.DropTable(
  302. name: "MemberDailyRewardCounter");
  303. migrationBuilder.DropColumn(
  304. name: "Attendance_BaseExp",
  305. table: "Config");
  306. migrationBuilder.DropColumn(
  307. name: "Attendance_BasePoint",
  308. table: "Config");
  309. migrationBuilder.DropColumn(
  310. name: "Attendance_IsEnabled",
  311. table: "Config");
  312. migrationBuilder.DropColumn(
  313. name: "Attendance_RankBonusConfig",
  314. table: "Config");
  315. migrationBuilder.DropColumn(
  316. name: "Attendance_StreakBonusMaxDays",
  317. table: "Config");
  318. migrationBuilder.DropColumn(
  319. name: "Attendance_StreakBonusPerDay",
  320. table: "Config");
  321. migrationBuilder.DropColumn(
  322. name: "Attendance_StreakBonusPointPerDay",
  323. table: "Config");
  324. migrationBuilder.DropColumn(
  325. name: "Attendance_UseRankBonus",
  326. table: "Config");
  327. migrationBuilder.DropColumn(
  328. name: "Attendance_UseStreakBonus",
  329. table: "Config");
  330. migrationBuilder.DropColumn(
  331. name: "Reward_CommentDailyCount",
  332. table: "Config");
  333. migrationBuilder.DropColumn(
  334. name: "Reward_CommentDailyExp",
  335. table: "Config");
  336. migrationBuilder.DropColumn(
  337. name: "Reward_CommentDailyPoint",
  338. table: "Config");
  339. migrationBuilder.DropColumn(
  340. name: "Reward_CommentExp",
  341. table: "Config");
  342. migrationBuilder.DropColumn(
  343. name: "Reward_CommentPoint",
  344. table: "Config");
  345. migrationBuilder.DropColumn(
  346. name: "Reward_LikeGivenDailyCount",
  347. table: "Config");
  348. migrationBuilder.DropColumn(
  349. name: "Reward_LikeGivenDailyExp",
  350. table: "Config");
  351. migrationBuilder.DropColumn(
  352. name: "Reward_LikeGivenExp",
  353. table: "Config");
  354. migrationBuilder.DropColumn(
  355. name: "Reward_LikeReceivedDailyCount",
  356. table: "Config");
  357. migrationBuilder.DropColumn(
  358. name: "Reward_LikeReceivedDailyPoint",
  359. table: "Config");
  360. migrationBuilder.DropColumn(
  361. name: "Reward_LikeReceivedPoint",
  362. table: "Config");
  363. migrationBuilder.DropColumn(
  364. name: "Reward_MinCommentLength",
  365. table: "Config");
  366. migrationBuilder.DropColumn(
  367. name: "Reward_MinPostLength",
  368. table: "Config");
  369. migrationBuilder.DropColumn(
  370. name: "Reward_NewMemberHoldDays",
  371. table: "Config");
  372. migrationBuilder.DropColumn(
  373. name: "Reward_PostDailyCount",
  374. table: "Config");
  375. migrationBuilder.DropColumn(
  376. name: "Reward_PostDailyExp",
  377. table: "Config");
  378. migrationBuilder.DropColumn(
  379. name: "Reward_PostDailyPoint",
  380. table: "Config");
  381. migrationBuilder.DropColumn(
  382. name: "Reward_PostExp",
  383. table: "Config");
  384. migrationBuilder.DropColumn(
  385. name: "Reward_PostPoint",
  386. table: "Config");
  387. migrationBuilder.DropColumn(
  388. name: "SignupReward_CashAmount",
  389. table: "Config");
  390. migrationBuilder.DropColumn(
  391. name: "SignupReward_CoinAmount",
  392. table: "Config");
  393. migrationBuilder.DropColumn(
  394. name: "SignupReward_Enabled",
  395. table: "Config");
  396. migrationBuilder.DropColumn(
  397. name: "SignupReward_ExpAmount",
  398. table: "Config");
  399. }
  400. }
  401. }