20260706033713_AddMemberTrackRecord.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Infrastructure.Migrations.AppDb
  5. {
  6. /// <inheritdoc />
  7. public partial class AddMemberTrackRecord : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.CreateTable(
  13. name: "MemberTrackRecord",
  14. columns: table => new
  15. {
  16. MemberID = table.Column<int>(type: "int", nullable: false, comment: "회원 ID (PK)"),
  17. Predictions = table.Column<int>(type: "int", nullable: false, comment: "채점 완료 예측 총계 (Hits+Misses+Voids)"),
  18. Hits = table.Column<int>(type: "int", nullable: false, comment: "적중 수"),
  19. Misses = table.Column<int>(type: "int", nullable: false, comment: "실패 수"),
  20. Voids = table.Column<int>(type: "int", nullable: false, comment: "무효 수 (표본 제외)"),
  21. HitRate = table.Column<decimal>(type: "decimal(5,2)", precision: 5, scale: 2, nullable: false, comment: "적중률 % (Hits/(Hits+Misses)*100)"),
  22. CurrentStreak = table.Column<int>(type: "int", nullable: false, comment: "현재 연속 적중"),
  23. BestStreak = table.Column<int>(type: "int", nullable: false, comment: "역대 최고 연속 적중"),
  24. Tier = table.Column<byte>(type: "tinyint", nullable: false, comment: "배지 등급 (0=None/1=Bronze/2=Silver/3=Gold/4=GoldAnt)"),
  25. UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "갱신 일시")
  26. },
  27. constraints: table =>
  28. {
  29. table.PrimaryKey("PK_MemberTrackRecord", x => x.MemberID);
  30. table.ForeignKey(
  31. name: "FK_MemberTrackRecord_Member_MemberID",
  32. column: x => x.MemberID,
  33. principalTable: "Member",
  34. principalColumn: "ID",
  35. onDelete: ReferentialAction.Cascade);
  36. },
  37. comment: "회원 예측 트랙레코드 집계 (적중률 배지·리더보드)");
  38. migrationBuilder.CreateIndex(
  39. name: "IX_MemberTrackRecord_HitRate",
  40. table: "MemberTrackRecord",
  41. column: "HitRate",
  42. descending: new bool[0],
  43. filter: "[Predictions] >= 10");
  44. }
  45. /// <inheritdoc />
  46. protected override void Down(MigrationBuilder migrationBuilder)
  47. {
  48. migrationBuilder.DropTable(
  49. name: "MemberTrackRecord");
  50. }
  51. }
  52. }