20260219091041_AddCoinMarketTable.cs 2.1 KB

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