| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- using System;
- using Microsoft.EntityFrameworkCore.Migrations;
- #nullable disable
- namespace Infrastructure.Migrations.AppDb;
- /// <inheritdoc />
- public partial class AddChannelTitlesSystem : Migration
- {
- /// <inheritdoc />
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "ChannelTitle",
- columns: table => new
- {
- ID = table.Column<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- ChannelID = table.Column<int>(type: "int", nullable: false, comment: "채널 ID"),
- Name = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false, comment: "칭호 이름"),
- Description = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "칭호 설명"),
- MinAmount = table.Column<long>(type: "bigint", nullable: false, comment: "획득 조건 (누적 후원 최소 금액)"),
- Color = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false, comment: "칭호 색상 (hex)"),
- IconUrl = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true, comment: "칭호 아이콘 URL"),
- SortOrder = table.Column<int>(type: "int", nullable: false, comment: "정렬 순서"),
- IsActive = table.Column<bool>(type: "bit", nullable: false, comment: "활성 여부"),
- UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "수정 일시"),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "생성 일시")
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ChannelTitle", x => x.ID);
- table.ForeignKey(
- name: "FK_ChannelTitle_Channel_ChannelID",
- column: x => x.ChannelID,
- principalTable: "Channel",
- principalColumn: "ID",
- onDelete: ReferentialAction.Cascade);
- },
- comment: "채널별 칭호 (크리에이터 설정)");
- migrationBuilder.CreateTable(
- name: "DonorChannelStats",
- columns: table => new
- {
- DonorMemberID = table.Column<int>(type: "int", nullable: false, comment: "후원자 회원 ID"),
- ChannelID = table.Column<int>(type: "int", nullable: false, comment: "채널 ID"),
- CumulativeAmount = table.Column<long>(type: "bigint", nullable: false, comment: "누적 후원 금액"),
- DonationCount = table.Column<int>(type: "int", nullable: false, comment: "후원 횟수"),
- FirstDonatedAt = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "첫 후원 일시"),
- LastDonatedAt = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "마지막 후원 일시"),
- UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "수정 일시"),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "생성 일시")
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_DonorChannelStats", x => new { x.DonorMemberID, x.ChannelID });
- table.ForeignKey(
- name: "FK_DonorChannelStats_Channel_ChannelID",
- column: x => x.ChannelID,
- principalTable: "Channel",
- principalColumn: "ID");
- table.ForeignKey(
- name: "FK_DonorChannelStats_Member_DonorMemberID",
- column: x => x.DonorMemberID,
- principalTable: "Member",
- principalColumn: "ID");
- },
- comment: "후원자×채널 누적 후원 (칭호 획득 판정용)");
- migrationBuilder.CreateTable(
- name: "DonorTitleSelection",
- columns: table => new
- {
- ID = table.Column<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- DonorMemberID = table.Column<int>(type: "int", nullable: false, comment: "후원자 회원 ID"),
- ChannelID = table.Column<int>(type: "int", nullable: false, comment: "채널 ID"),
- SelectedTitleID = table.Column<int>(type: "int", nullable: true, comment: "선택 칭호 ID"),
- UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "수정 일시"),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "생성 일시")
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_DonorTitleSelection", x => x.ID);
- table.ForeignKey(
- name: "FK_DonorTitleSelection_ChannelTitle_SelectedTitleID",
- column: x => x.SelectedTitleID,
- principalTable: "ChannelTitle",
- principalColumn: "ID",
- onDelete: ReferentialAction.SetNull);
- table.ForeignKey(
- name: "FK_DonorTitleSelection_Channel_ChannelID",
- column: x => x.ChannelID,
- principalTable: "Channel",
- principalColumn: "ID");
- table.ForeignKey(
- name: "FK_DonorTitleSelection_Member_DonorMemberID",
- column: x => x.DonorMemberID,
- principalTable: "Member",
- principalColumn: "ID");
- },
- comment: "후원자가 선택한 채널별 대표 칭호");
- migrationBuilder.CreateIndex(
- name: "IX_ChannelTitle_ChannelID_MinAmount",
- table: "ChannelTitle",
- columns: new[] { "ChannelID", "MinAmount" });
- migrationBuilder.CreateIndex(
- name: "IX_ChannelTitle_ChannelID_SortOrder",
- table: "ChannelTitle",
- columns: new[] { "ChannelID", "SortOrder" });
- migrationBuilder.CreateIndex(
- name: "IX_DonorChannelStats_ChannelID_CumulativeAmount",
- table: "DonorChannelStats",
- columns: new[] { "ChannelID", "CumulativeAmount" },
- descending: new[] { false, true });
- migrationBuilder.CreateIndex(
- name: "IX_DonorTitleSelection_ChannelID",
- table: "DonorTitleSelection",
- column: "ChannelID");
- migrationBuilder.CreateIndex(
- name: "IX_DonorTitleSelection_DonorMemberID_ChannelID",
- table: "DonorTitleSelection",
- columns: new[] { "DonorMemberID", "ChannelID" },
- unique: true);
- migrationBuilder.CreateIndex(
- name: "IX_DonorTitleSelection_SelectedTitleID",
- table: "DonorTitleSelection",
- column: "SelectedTitleID");
- }
- /// <inheritdoc />
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "DonorChannelStats");
- migrationBuilder.DropTable(
- name: "DonorTitleSelection");
- migrationBuilder.DropTable(
- name: "ChannelTitle");
- }
- }
|