20260323065100_RemoveCrypto.cs 10 KB

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