| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- using System;
- using Microsoft.EntityFrameworkCore.Migrations;
- #nullable disable
- namespace Infrastructure.Migrations.AppDb
- {
- /// <inheritdoc />
- public partial class AddConsumableItemsAndProfileCooldown : Migration
- {
- /// <inheritdoc />
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AlterColumn<int>(
- name: "GameID",
- table: "Product",
- type: "int",
- nullable: true,
- comment: "게임 ID (선택 — null=플랫폼 직접판매)",
- oldClrType: typeof(int),
- oldType: "int");
- migrationBuilder.AddColumn<int>(
- name: "DurationDays",
- table: "Product",
- type: "int",
- nullable: false,
- defaultValue: 0,
- comment: "소모품 효과 지속일 (0=즉시소모)");
- migrationBuilder.AddColumn<byte>(
- name: "ItemKind",
- table: "Product",
- type: "tinyint",
- nullable: true,
- comment: "소모품 종류 (null=일반상품, 5~11=소모품)");
- migrationBuilder.AddColumn<DateTime>(
- name: "LastThumbChangedAt",
- table: "Member",
- type: "datetime2",
- nullable: true);
- migrationBuilder.AddColumn<int>(
- name: "Account_ChangeThumbDay",
- table: "Config",
- type: "int",
- nullable: true,
- comment: "프로필 이미지 갱신 주기(일)");
- migrationBuilder.CreateTable(
- name: "MemberItem",
- columns: table => new
- {
- ID = table.Column<int>(type: "int", nullable: false, comment: "PK")
- .Annotation("SqlServer:Identity", "1, 1"),
- MemberID = table.Column<int>(type: "int", nullable: false, comment: "회원 ID"),
- ProductID = table.Column<int>(type: "int", nullable: false, comment: "상품 ID"),
- OrderItemID = table.Column<int>(type: "int", nullable: false, comment: "발급 근거 주문항목 ID"),
- Kind = table.Column<byte>(type: "tinyint", nullable: false, comment: "아이템 종류 (5~11)"),
- DurationDays = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "효과 지속일 (0=즉시소모)"),
- AcquiredAt = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "획득 일시"),
- UsedAt = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "소모/활성 일시 (null=미사용)"),
- RevokedAt = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "회수 일시 (환불)"),
- RowVersion = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_MemberItem", x => x.ID);
- table.ForeignKey(
- name: "FK_MemberItem_Member_MemberID",
- column: x => x.MemberID,
- principalTable: "Member",
- principalColumn: "ID",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_MemberItem_Product_ProductID",
- column: x => x.ProductID,
- principalTable: "Product",
- principalColumn: "ID",
- onDelete: ReferentialAction.Restrict);
- },
- comment: "계정 귀속 소모품 아이템");
- migrationBuilder.CreateTable(
- name: "MemberItemUsageLog",
- columns: table => new
- {
- ID = table.Column<int>(type: "int", nullable: false, comment: "PK")
- .Annotation("SqlServer:Identity", "1, 1"),
- MemberID = table.Column<int>(type: "int", nullable: false, comment: "회원 ID"),
- MemberItemID = table.Column<int>(type: "int", nullable: false, comment: "MemberItem ID"),
- ProductID = table.Column<int>(type: "int", nullable: false, comment: "상품 ID"),
- Kind = table.Column<byte>(type: "tinyint", nullable: false, comment: "아이템 종류"),
- Action = table.Column<byte>(type: "tinyint", nullable: false, comment: "액션 (1=Used, 2=Revoked)"),
- Detail = table.Column<string>(type: "nvarchar(300)", maxLength: 300, nullable: true, comment: "결과 요약"),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "등록 일시")
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_MemberItemUsageLog", x => x.ID);
- },
- comment: "소모품 아이템 사용/회수 로그");
- migrationBuilder.CreateTable(
- name: "MemberThumbChangeLog",
- columns: table => new
- {
- ID = table.Column<int>(type: "int", nullable: false, comment: "PK")
- .Annotation("SqlServer:Identity", "1, 1"),
- MemberID = table.Column<int>(type: "int", nullable: false, comment: "회원 ID"),
- BeforeThumb = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true, comment: "이전 이미지"),
- AfterThumb = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true, comment: "바꾼 이미지"),
- Referer = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "이전 페이지 주소"),
- IpAddress = table.Column<string>(type: "nvarchar(45)", maxLength: 45, nullable: true, comment: "IP Address (IPv6 호환)"),
- UserAgent = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true, comment: "User Agent"),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "등록 일시")
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_MemberThumbChangeLog", x => x.ID);
- table.ForeignKey(
- name: "FK_MemberThumbChangeLog_Member_MemberID",
- column: x => x.MemberID,
- principalTable: "Member",
- principalColumn: "ID",
- onDelete: ReferentialAction.Cascade);
- },
- comment: "프로필 이미지 변경 내역");
- migrationBuilder.CreateIndex(
- name: "IX_Product_ItemKind_IsActive",
- table: "Product",
- columns: new[] { "ItemKind", "IsActive" });
- migrationBuilder.CreateIndex(
- name: "IX_MemberItem_MemberID_Kind_UsedAt",
- table: "MemberItem",
- columns: new[] { "MemberID", "Kind", "UsedAt" });
- migrationBuilder.CreateIndex(
- name: "IX_MemberItem_OrderItemID",
- table: "MemberItem",
- column: "OrderItemID");
- migrationBuilder.CreateIndex(
- name: "IX_MemberItem_ProductID",
- table: "MemberItem",
- column: "ProductID");
- migrationBuilder.CreateIndex(
- name: "IX_MemberItemUsageLog_MemberID_CreatedAt",
- table: "MemberItemUsageLog",
- columns: new[] { "MemberID", "CreatedAt" });
- migrationBuilder.CreateIndex(
- name: "IX_MemberThumbChangeLog_MemberID",
- table: "MemberThumbChangeLog",
- column: "MemberID");
- // 기존 Config 싱글턴에 프로필(닉네임·한마디·이미지) 90일 쿨다운 활성화 — Wave 3 P3 결정 #3.
- // Name/Intro 는 미설정(NULL)일 때만 90 으로, Thumb 는 신규 컬럼이라 전부 90 으로 채운다.
- migrationBuilder.Sql(@"
- UPDATE [Config]
- SET [Account_ChangeNameDay] = COALESCE([Account_ChangeNameDay], 90),
- [Account_ChangeIntroDay] = COALESCE([Account_ChangeIntroDay], 90),
- [Account_ChangeThumbDay] = 90
- WHERE [Account_ChangeThumbDay] IS NULL;");
- }
- /// <inheritdoc />
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "MemberItem");
- migrationBuilder.DropTable(
- name: "MemberItemUsageLog");
- migrationBuilder.DropTable(
- name: "MemberThumbChangeLog");
- migrationBuilder.DropIndex(
- name: "IX_Product_ItemKind_IsActive",
- table: "Product");
- migrationBuilder.DropColumn(
- name: "DurationDays",
- table: "Product");
- migrationBuilder.DropColumn(
- name: "ItemKind",
- table: "Product");
- migrationBuilder.DropColumn(
- name: "LastThumbChangedAt",
- table: "Member");
- migrationBuilder.DropColumn(
- name: "Account_ChangeThumbDay",
- table: "Config");
- migrationBuilder.AlterColumn<int>(
- name: "GameID",
- table: "Product",
- type: "int",
- nullable: false,
- defaultValue: 0,
- comment: "게임 ID (필수)",
- oldClrType: typeof(int),
- oldType: "int",
- oldNullable: true,
- oldComment: "게임 ID (선택 — null=플랫폼 직접판매)");
- }
- }
- }
|