using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Infrastructure.Migrations.AppDb { /// public partial class EnrichGameWithFdmboxFields : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { // 기존 Name 인덱스 제거 migrationBuilder.DropIndex( name: "IX_Game_Name", table: "Game"); // Name → KorName 컬럼 rename (기존 데이터 보존) migrationBuilder.Sql("EXEC sp_rename N'[Game].[Name]', N'KorName', N'COLUMN';"); // KorName 컬럼 길이/주석 변경 (nvarchar(100) → nvarchar(255)) migrationBuilder.AlterColumn( name: "KorName", table: "Game", type: "nvarchar(255)", maxLength: 255, nullable: false, comment: "게임 한글명", oldClrType: typeof(string), oldType: "nvarchar(100)", oldMaxLength: 100, oldComment: "게임 이름"); // Description : nvarchar(2000) → nvarchar(max) migrationBuilder.AlterColumn( name: "Description", table: "Game", type: "nvarchar(max)", nullable: true, comment: "게임 소개 (CKEditor HTML)", oldClrType: typeof(string), oldType: "nvarchar(2000)", oldMaxLength: 2000, oldNullable: true, oldComment: "게임 소개 (CKEditor HTML)"); // 신규 컬럼: Code (6자 UNIQUE filtered) migrationBuilder.AddColumn( name: "Code", table: "Game", type: "nvarchar(6)", maxLength: 6, nullable: true, comment: "게임 코드 (UNIQUE, 외부 연동/내부 식별)"); // 신규 컬럼: EngName migrationBuilder.AddColumn( name: "EngName", table: "Game", type: "nvarchar(255)", maxLength: 255, nullable: true, comment: "게임 영문명"); // 신규 컬럼: Link migrationBuilder.AddColumn( name: "Link", table: "Game", type: "nvarchar(255)", maxLength: 255, nullable: true, comment: "게임 다운로드/공식 사이트 주소"); // KorName UNIQUE migrationBuilder.CreateIndex( name: "IX_Game_KorName", table: "Game", column: "KorName", unique: true); // Code UNIQUE (NULL 제외) migrationBuilder.CreateIndex( name: "IX_Game_Code", table: "Game", column: "Code", unique: true, filter: "[Code] IS NOT NULL"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropIndex( name: "IX_Game_Code", table: "Game"); migrationBuilder.DropIndex( name: "IX_Game_KorName", table: "Game"); migrationBuilder.DropColumn( name: "Code", table: "Game"); migrationBuilder.DropColumn( name: "EngName", table: "Game"); migrationBuilder.DropColumn( name: "Link", table: "Game"); migrationBuilder.AlterColumn( name: "Description", table: "Game", type: "nvarchar(2000)", maxLength: 2000, nullable: true, oldClrType: typeof(string), oldType: "nvarchar(max)", oldNullable: true, oldComment: "게임 소개 (CKEditor HTML)"); migrationBuilder.AlterColumn( name: "KorName", table: "Game", type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "게임 이름", oldClrType: typeof(string), oldType: "nvarchar(255)", oldMaxLength: 255, oldComment: "게임 한글명"); migrationBuilder.Sql("EXEC sp_rename N'[Game].[KorName]', N'Name', N'COLUMN';"); migrationBuilder.CreateIndex( name: "IX_Game_Name", table: "Game", column: "Name", unique: true); } } }