20260323065100_RemoveCrypto.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Infrastructure.Migrations.AppDb;
  5. /// <inheritdoc />
  6. public partial class RemoveCrypto : Migration
  7. {
  8. /// <inheritdoc />
  9. protected override void Up(MigrationBuilder migrationBuilder)
  10. {
  11. migrationBuilder.DropForeignKey(
  12. name: "FK_Board_Coin_CoinID",
  13. table: "Board");
  14. migrationBuilder.DropTable(
  15. name: "CoinCategoryMap");
  16. migrationBuilder.DropTable(
  17. name: "CoinMarket");
  18. migrationBuilder.DropTable(
  19. name: "CoinCategory");
  20. migrationBuilder.DropTable(
  21. name: "Coin");
  22. migrationBuilder.DropIndex(
  23. name: "IX_Board_CoinID",
  24. table: "Board");
  25. migrationBuilder.DropColumn(
  26. name: "CoinID",
  27. table: "Board");
  28. }
  29. /// <inheritdoc />
  30. protected override void Down(MigrationBuilder migrationBuilder)
  31. {
  32. migrationBuilder.AddColumn<int>(
  33. name: "CoinID",
  34. table: "Board",
  35. type: "int",
  36. nullable: true);
  37. migrationBuilder.CreateTable(
  38. name: "Coin",
  39. columns: table => new
  40. {
  41. ID = table.Column<int>(type: "int", nullable: false, comment: "PK")
  42. .Annotation("SqlServer:Identity", "1, 1"),
  43. ContractAddress = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "컨트랙트 주소"),
  44. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "등록 일시"),
  45. Description = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "설명"),
  46. DisplayOrder = table.Column<short>(type: "smallint", nullable: false, comment: "메인 노출 순서"),
  47. EngName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false, comment: "영문 이름"),
  48. IsActive = table.Column<bool>(type: "bit", nullable: false, comment: "사용 여부"),
  49. IsDelisted = table.Column<bool>(type: "bit", nullable: false, comment: "상장 폐지"),
  50. IsFeatured = table.Column<bool>(type: "bit", nullable: false, comment: "주요 코인 (메인 노출)"),
  51. IsNew = table.Column<bool>(type: "bit", nullable: false, comment: "신규 상장"),
  52. IsWarning = table.Column<bool>(type: "bit", nullable: false, comment: "위험 경고"),
  53. KorName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false, comment: "한글 이름"),
  54. LogoImage = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true, comment: "로고 이미지"),
  55. Symbol = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false, comment: "심볼 (BTC, ETH 등)"),
  56. TelegramUrl = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true, comment: "텔레그램 URL"),
  57. TwitterUrl = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true, comment: "트위터 URL"),
  58. UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "수정 일시"),
  59. WebsiteUrl = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true, comment: "홈페이지 URL"),
  60. WhitepaperUrl = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true, comment: "백서 URL")
  61. },
  62. constraints: table =>
  63. {
  64. table.PrimaryKey("PK_Coin", x => x.ID);
  65. },
  66. comment: "코인/토큰");
  67. migrationBuilder.CreateTable(
  68. name: "CoinCategory",
  69. columns: table => new
  70. {
  71. ID = table.Column<int>(type: "int", nullable: false, comment: "PK")
  72. .Annotation("SqlServer:Identity", "1, 1"),
  73. Code = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false, comment: "카테고리 코드"),
  74. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "등록 일시"),
  75. IsActive = table.Column<bool>(type: "bit", nullable: false, comment: "사용 여부"),
  76. Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "카테고리 이름"),
  77. Order = table.Column<short>(type: "smallint", nullable: false, comment: "순서"),
  78. UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "수정 일시")
  79. },
  80. constraints: table =>
  81. {
  82. table.PrimaryKey("PK_CoinCategory", x => x.ID);
  83. },
  84. comment: "코인 카테고리");
  85. migrationBuilder.CreateTable(
  86. name: "CoinMarket",
  87. columns: table => new
  88. {
  89. ID = table.Column<int>(type: "int", nullable: false, comment: "PK")
  90. .Annotation("SqlServer:Identity", "1, 1"),
  91. CoinID = table.Column<int>(type: "int", nullable: false, comment: "코인 ID"),
  92. Market = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false, comment: "거래쌍 (KRW-BTC 등)")
  93. },
  94. constraints: table =>
  95. {
  96. table.PrimaryKey("PK_CoinMarket", x => x.ID);
  97. table.ForeignKey(
  98. name: "FK_CoinMarket_Coin_CoinID",
  99. column: x => x.CoinID,
  100. principalTable: "Coin",
  101. principalColumn: "ID",
  102. onDelete: ReferentialAction.Cascade);
  103. },
  104. comment: "코인-거래쌍 연결");
  105. migrationBuilder.CreateTable(
  106. name: "CoinCategoryMap",
  107. columns: table => new
  108. {
  109. ID = table.Column<int>(type: "int", nullable: false, comment: "PK")
  110. .Annotation("SqlServer:Identity", "1, 1"),
  111. CategoryID = table.Column<int>(type: "int", nullable: false, comment: "카테고리 ID"),
  112. CoinID = table.Column<int>(type: "int", nullable: false, comment: "코인 ID")
  113. },
  114. constraints: table =>
  115. {
  116. table.PrimaryKey("PK_CoinCategoryMap", x => x.ID);
  117. table.ForeignKey(
  118. name: "FK_CoinCategoryMap_CoinCategory_CategoryID",
  119. column: x => x.CategoryID,
  120. principalTable: "CoinCategory",
  121. principalColumn: "ID",
  122. onDelete: ReferentialAction.Restrict);
  123. table.ForeignKey(
  124. name: "FK_CoinCategoryMap_Coin_CoinID",
  125. column: x => x.CoinID,
  126. principalTable: "Coin",
  127. principalColumn: "ID",
  128. onDelete: ReferentialAction.Cascade);
  129. },
  130. comment: "코인-카테고리 연결");
  131. migrationBuilder.CreateIndex(
  132. name: "IX_Board_CoinID",
  133. table: "Board",
  134. column: "CoinID");
  135. migrationBuilder.CreateIndex(
  136. name: "IX_Coin_DisplayOrder",
  137. table: "Coin",
  138. column: "DisplayOrder");
  139. migrationBuilder.CreateIndex(
  140. name: "IX_Coin_IsActive",
  141. table: "Coin",
  142. column: "IsActive");
  143. migrationBuilder.CreateIndex(
  144. name: "IX_Coin_IsDelisted",
  145. table: "Coin",
  146. column: "IsDelisted");
  147. migrationBuilder.CreateIndex(
  148. name: "IX_Coin_IsFeatured",
  149. table: "Coin",
  150. column: "IsFeatured");
  151. migrationBuilder.CreateIndex(
  152. name: "IX_Coin_IsNew",
  153. table: "Coin",
  154. column: "IsNew");
  155. migrationBuilder.CreateIndex(
  156. name: "IX_Coin_IsWarning",
  157. table: "Coin",
  158. column: "IsWarning");
  159. migrationBuilder.CreateIndex(
  160. name: "IX_Coin_Symbol",
  161. table: "Coin",
  162. column: "Symbol",
  163. unique: true);
  164. migrationBuilder.CreateIndex(
  165. name: "IX_Coin_Symbol_IsActive",
  166. table: "Coin",
  167. columns: new[] { "Symbol", "IsActive" });
  168. migrationBuilder.CreateIndex(
  169. name: "IX_CoinCategory_Code",
  170. table: "CoinCategory",
  171. column: "Code",
  172. unique: true);
  173. migrationBuilder.CreateIndex(
  174. name: "IX_CoinCategory_IsActive",
  175. table: "CoinCategory",
  176. column: "IsActive");
  177. migrationBuilder.CreateIndex(
  178. name: "IX_CoinCategory_Order",
  179. table: "CoinCategory",
  180. column: "Order");
  181. migrationBuilder.CreateIndex(
  182. name: "IX_CoinCategoryMap_CategoryID",
  183. table: "CoinCategoryMap",
  184. column: "CategoryID");
  185. migrationBuilder.CreateIndex(
  186. name: "IX_CoinCategoryMap_CoinID_CategoryID",
  187. table: "CoinCategoryMap",
  188. columns: new[] { "CoinID", "CategoryID" },
  189. unique: true);
  190. migrationBuilder.CreateIndex(
  191. name: "IX_CoinMarket_CoinID_Market",
  192. table: "CoinMarket",
  193. columns: new[] { "CoinID", "Market" },
  194. unique: true);
  195. migrationBuilder.CreateIndex(
  196. name: "IX_CoinMarket_Market",
  197. table: "CoinMarket",
  198. column: "Market");
  199. migrationBuilder.AddForeignKey(
  200. name: "FK_Board_Coin_CoinID",
  201. table: "Board",
  202. column: "CoinID",
  203. principalTable: "Coin",
  204. principalColumn: "ID",
  205. onDelete: ReferentialAction.SetNull);
  206. }
  207. }