20260217052032_AddCrypto.cs 7.7 KB

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