20260219091041_AddCoinMarketTable.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using Microsoft.EntityFrameworkCore.Migrations;
  2. #nullable disable
  3. namespace Infrastructure.Migrations.AppDb
  4. {
  5. /// <inheritdoc />
  6. public partial class AddCoinMarketTable : Migration
  7. {
  8. /// <inheritdoc />
  9. protected override void Up(MigrationBuilder migrationBuilder)
  10. {
  11. migrationBuilder.DropColumn(
  12. name: "Market",
  13. table: "Coin");
  14. migrationBuilder.CreateTable(
  15. name: "CoinMarket",
  16. columns: table => new
  17. {
  18. ID = table.Column<int>(type: "int", nullable: false, comment: "PK")
  19. .Annotation("SqlServer:Identity", "1, 1"),
  20. CoinID = table.Column<int>(type: "int", nullable: false, comment: "코인 ID"),
  21. Market = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false, comment: "거래쌍 (KRW-BTC 등)")
  22. },
  23. constraints: table =>
  24. {
  25. table.PrimaryKey("PK_CoinMarket", x => x.ID);
  26. table.ForeignKey(
  27. name: "FK_CoinMarket_Coin_CoinID",
  28. column: x => x.CoinID,
  29. principalTable: "Coin",
  30. principalColumn: "ID",
  31. onDelete: ReferentialAction.Cascade);
  32. },
  33. comment: "코인-거래쌍 연결");
  34. migrationBuilder.CreateIndex(
  35. name: "IX_CoinMarket_CoinID_Market",
  36. table: "CoinMarket",
  37. columns: new[] { "CoinID", "Market" },
  38. unique: true);
  39. migrationBuilder.CreateIndex(
  40. name: "IX_CoinMarket_Market",
  41. table: "CoinMarket",
  42. column: "Market");
  43. }
  44. /// <inheritdoc />
  45. protected override void Down(MigrationBuilder migrationBuilder)
  46. {
  47. migrationBuilder.DropTable(
  48. name: "CoinMarket");
  49. migrationBuilder.AddColumn<string>(
  50. name: "Market",
  51. table: "Coin",
  52. type: "nvarchar(30)",
  53. maxLength: 30,
  54. nullable: false,
  55. defaultValue: "",
  56. comment: "거래쌍 (KRW-BTC 등)");
  57. }
  58. }
  59. }