using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Persistence.Migrations
{
///
public partial class AddGameDetailFields : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn(
name: "MinSpec",
table: "Game",
type: "nvarchar(max)",
nullable: true,
comment: "최소 사양 (자유 텍스트)");
migrationBuilder.AddColumn(
name: "RecommendedSpec",
table: "Game",
type: "nvarchar(max)",
nullable: true,
comment: "권장 사양 (자유 텍스트)");
migrationBuilder.AddColumn(
name: "TrailerUrl",
table: "Game",
type: "nvarchar(500)",
maxLength: 500,
nullable: true,
comment: "YouTube 예고편 URL");
migrationBuilder.CreateTable(
name: "GameCategory",
columns: table => new
{
ID = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
KorName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "카테고리 한글명"),
EngName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "카테고리 영문명"),
Order = table.Column(type: "int", nullable: false),
IsActive = table.Column(type: "bit", nullable: false),
CreatedAt = table.Column(type: "datetime2", nullable: false),
UpdatedAt = table.Column(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GameCategory", x => x.ID);
},
comment: "게임 카테고리 코드");
migrationBuilder.CreateTable(
name: "GameGenre",
columns: table => new
{
ID = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
KorName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "장르 한글명"),
EngName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "장르 영문명"),
Order = table.Column(type: "int", nullable: false),
IsActive = table.Column(type: "bit", nullable: false),
CreatedAt = table.Column(type: "datetime2", nullable: false),
UpdatedAt = table.Column(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GameGenre", x => x.ID);
},
comment: "게임 장르 코드");
migrationBuilder.CreateTable(
name: "GameImage",
columns: table => new
{
ID = table.Column(type: "int", nullable: false, comment: "PK")
.Annotation("SqlServer:Identity", "1, 1"),
GameID = table.Column(type: "int", nullable: false),
UUID = table.Column(type: "uniqueidentifier", nullable: false, comment: "UUID"),
FileName = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false, comment: "원본 파일명"),
HashedName = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false, comment: "저장 파일명(해시)"),
Path = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false, comment: "상대 경로"),
Url = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: false, comment: "접근 URL"),
Extension = table.Column(type: "nvarchar(10)", maxLength: 10, nullable: true, comment: "확장자"),
ContentType = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "MIME"),
Size = table.Column(type: "bigint", nullable: true, comment: "바이트 크기"),
Width = table.Column(type: "smallint", nullable: true, comment: "가로 픽셀"),
Height = table.Column(type: "smallint", nullable: true, comment: "세로 픽셀"),
Order = table.Column(type: "int", nullable: false, comment: "정렬 순서"),
IsDisabled = table.Column(type: "bit", nullable: false, comment: "비활성 여부"),
DisabledAt = table.Column(type: "datetime2", nullable: true, comment: "비활성 일시"),
CreatedAt = table.Column(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GameImage", x => x.ID);
table.ForeignKey(
name: "FK_GameImage_Game_GameID",
column: x => x.GameID,
principalTable: "Game",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
},
comment: "게임 상세 이미지 갤러리");
migrationBuilder.CreateTable(
name: "GameCategoryMap",
columns: table => new
{
GameID = table.Column(type: "int", nullable: false),
GameCategoryID = table.Column(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GameCategoryMap", x => new { x.GameID, x.GameCategoryID });
table.ForeignKey(
name: "FK_GameCategoryMap_GameCategory_GameCategoryID",
column: x => x.GameCategoryID,
principalTable: "GameCategory",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GameCategoryMap_Game_GameID",
column: x => x.GameID,
principalTable: "Game",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
},
comment: "게임-카테고리 N:M");
migrationBuilder.CreateTable(
name: "GameGenreMap",
columns: table => new
{
GameID = table.Column(type: "int", nullable: false),
GameGenreID = table.Column(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GameGenreMap", x => new { x.GameID, x.GameGenreID });
table.ForeignKey(
name: "FK_GameGenreMap_GameGenre_GameGenreID",
column: x => x.GameGenreID,
principalTable: "GameGenre",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GameGenreMap_Game_GameID",
column: x => x.GameID,
principalTable: "Game",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
},
comment: "게임-장르 N:M");
migrationBuilder.CreateIndex(
name: "IX_GameCategory_IsActive_Order",
table: "GameCategory",
columns: new[] { "IsActive", "Order" });
migrationBuilder.CreateIndex(
name: "IX_GameCategory_KorName",
table: "GameCategory",
column: "KorName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_GameCategoryMap_GameCategoryID",
table: "GameCategoryMap",
column: "GameCategoryID");
migrationBuilder.CreateIndex(
name: "IX_GameGenre_IsActive_Order",
table: "GameGenre",
columns: new[] { "IsActive", "Order" });
migrationBuilder.CreateIndex(
name: "IX_GameGenre_KorName",
table: "GameGenre",
column: "KorName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_GameGenreMap_GameGenreID",
table: "GameGenreMap",
column: "GameGenreID");
migrationBuilder.CreateIndex(
name: "IX_GameImage_GameID",
table: "GameImage",
column: "GameID");
migrationBuilder.CreateIndex(
name: "IX_GameImage_GameID_IsDisabled",
table: "GameImage",
columns: new[] { "GameID", "IsDisabled" });
migrationBuilder.CreateIndex(
name: "IX_GameImage_UUID",
table: "GameImage",
column: "UUID",
unique: true);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "GameCategoryMap");
migrationBuilder.DropTable(
name: "GameGenreMap");
migrationBuilder.DropTable(
name: "GameImage");
migrationBuilder.DropTable(
name: "GameCategory");
migrationBuilder.DropTable(
name: "GameGenre");
migrationBuilder.DropColumn(
name: "MinSpec",
table: "Game");
migrationBuilder.DropColumn(
name: "RecommendedSpec",
table: "Game");
migrationBuilder.DropColumn(
name: "TrailerUrl",
table: "Game");
}
}
}