20260217052032_AddCrypto.cs 8.3 KB

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