20260523134646_EnrichGameWithFdmboxFields.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. using Microsoft.EntityFrameworkCore.Migrations;
  2. #nullable disable
  3. namespace Infrastructure.Migrations.AppDb
  4. {
  5. /// <inheritdoc />
  6. public partial class EnrichGameWithFdmboxFields : Migration
  7. {
  8. /// <inheritdoc />
  9. protected override void Up(MigrationBuilder migrationBuilder)
  10. {
  11. // 기존 Name 인덱스 제거
  12. migrationBuilder.DropIndex(
  13. name: "IX_Game_Name",
  14. table: "Game");
  15. // Name → KorName 컬럼 rename (기존 데이터 보존)
  16. migrationBuilder.Sql("EXEC sp_rename N'[Game].[Name]', N'KorName', N'COLUMN';");
  17. // KorName 컬럼 길이/주석 변경 (nvarchar(100) → nvarchar(255))
  18. migrationBuilder.AlterColumn<string>(
  19. name: "KorName",
  20. table: "Game",
  21. type: "nvarchar(255)",
  22. maxLength: 255,
  23. nullable: false,
  24. comment: "게임 한글명",
  25. oldClrType: typeof(string),
  26. oldType: "nvarchar(100)",
  27. oldMaxLength: 100,
  28. oldComment: "게임 이름");
  29. // Description : nvarchar(2000) → nvarchar(max)
  30. migrationBuilder.AlterColumn<string>(
  31. name: "Description",
  32. table: "Game",
  33. type: "nvarchar(max)",
  34. nullable: true,
  35. comment: "게임 소개 (CKEditor HTML)",
  36. oldClrType: typeof(string),
  37. oldType: "nvarchar(2000)",
  38. oldMaxLength: 2000,
  39. oldNullable: true);
  40. // 신규 컬럼: Code (6자 UNIQUE filtered)
  41. migrationBuilder.AddColumn<string>(
  42. name: "Code",
  43. table: "Game",
  44. type: "nvarchar(6)",
  45. maxLength: 6,
  46. nullable: true,
  47. comment: "게임 코드 (UNIQUE, 외부 연동/내부 식별)");
  48. // 신규 컬럼: EngName
  49. migrationBuilder.AddColumn<string>(
  50. name: "EngName",
  51. table: "Game",
  52. type: "nvarchar(255)",
  53. maxLength: 255,
  54. nullable: true,
  55. comment: "게임 영문명");
  56. // 신규 컬럼: Link
  57. migrationBuilder.AddColumn<string>(
  58. name: "Link",
  59. table: "Game",
  60. type: "nvarchar(255)",
  61. maxLength: 255,
  62. nullable: true,
  63. comment: "게임 다운로드/공식 사이트 주소");
  64. // KorName UNIQUE
  65. migrationBuilder.CreateIndex(
  66. name: "IX_Game_KorName",
  67. table: "Game",
  68. column: "KorName",
  69. unique: true);
  70. // Code UNIQUE (NULL 제외)
  71. migrationBuilder.CreateIndex(
  72. name: "IX_Game_Code",
  73. table: "Game",
  74. column: "Code",
  75. unique: true,
  76. filter: "[Code] IS NOT NULL");
  77. }
  78. /// <inheritdoc />
  79. protected override void Down(MigrationBuilder migrationBuilder)
  80. {
  81. migrationBuilder.DropIndex(
  82. name: "IX_Game_Code",
  83. table: "Game");
  84. migrationBuilder.DropIndex(
  85. name: "IX_Game_KorName",
  86. table: "Game");
  87. migrationBuilder.DropColumn(
  88. name: "Code",
  89. table: "Game");
  90. migrationBuilder.DropColumn(
  91. name: "EngName",
  92. table: "Game");
  93. migrationBuilder.DropColumn(
  94. name: "Link",
  95. table: "Game");
  96. migrationBuilder.AlterColumn<string>(
  97. name: "Description",
  98. table: "Game",
  99. type: "nvarchar(2000)",
  100. maxLength: 2000,
  101. nullable: true,
  102. oldClrType: typeof(string),
  103. oldType: "nvarchar(max)",
  104. oldNullable: true,
  105. oldComment: "게임 소개 (CKEditor HTML)");
  106. migrationBuilder.AlterColumn<string>(
  107. name: "KorName",
  108. table: "Game",
  109. type: "nvarchar(100)",
  110. maxLength: 100,
  111. nullable: false,
  112. comment: "게임 이름",
  113. oldClrType: typeof(string),
  114. oldType: "nvarchar(255)",
  115. oldMaxLength: 255,
  116. oldComment: "게임 한글명");
  117. migrationBuilder.Sql("EXEC sp_rename N'[Game].[KorName]', N'Name', N'COLUMN';");
  118. migrationBuilder.CreateIndex(
  119. name: "IX_Game_Name",
  120. table: "Game",
  121. column: "Name",
  122. unique: true);
  123. }
  124. }
  125. }