20260709044353_AddMarketQuoteSnapshot.cs 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Infrastructure.Migrations.AppDb
  5. {
  6. /// <inheritdoc />
  7. public partial class AddMarketQuoteSnapshot : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.CreateTable(
  13. name: "MarketQuoteSnapshot",
  14. columns: table => new
  15. {
  16. ID = table.Column<long>(type: "bigint", nullable: false)
  17. .Annotation("SqlServer:Identity", "1, 1"),
  18. Symbol = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false, comment: "외부 소스(Stooq) 심볼"),
  19. Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "표시명"),
  20. Category = table.Column<int>(type: "int", nullable: false, comment: "0 Stock,1 Commodity,2 Futures,3 Fx,4 BondYield"),
  21. GroupCode = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: false, comment: "프론트 그룹 키"),
  22. CountryCode = table.Column<string>(type: "nvarchar(2)", maxLength: 2, nullable: false, comment: "국가 코드 (ISO2, 상품은 빈값)"),
  23. TradeDate = table.Column<DateOnly>(type: "date", nullable: false),
  24. Close = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "종가"),
  25. PrevClose = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "직전 거래일 종가"),
  26. ChangeVal = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "전일 대비"),
  27. FlucRateBp = table.Column<int>(type: "int", nullable: false, comment: "등락률 basis point (%×100)"),
  28. Open = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "시가"),
  29. High = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "고가"),
  30. Low = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "저가"),
  31. Volume = table.Column<long>(type: "bigint", nullable: false, comment: "거래량"),
  32. UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  33. },
  34. constraints: table =>
  35. {
  36. table.PrimaryKey("PK_MarketQuoteSnapshot", x => x.ID);
  37. },
  38. comment: "주요 종목·상품 시세 최신 스냅샷 (Stooq 일1회 upsert, 카테고리/그룹별)");
  39. migrationBuilder.CreateIndex(
  40. name: "IX_MarketQuoteSnapshot_Category_GroupCode",
  41. table: "MarketQuoteSnapshot",
  42. columns: new[] { "Category", "GroupCode" });
  43. migrationBuilder.CreateIndex(
  44. name: "IX_MarketQuoteSnapshot_Symbol",
  45. table: "MarketQuoteSnapshot",
  46. column: "Symbol",
  47. unique: true);
  48. }
  49. /// <inheritdoc />
  50. protected override void Down(MigrationBuilder migrationBuilder)
  51. {
  52. migrationBuilder.DropTable(
  53. name: "MarketQuoteSnapshot");
  54. }
  55. }
  56. }