20260706014543_AddMarketIndex.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Infrastructure.Migrations.AppDb
  5. {
  6. /// <inheritdoc />
  7. public partial class AddMarketIndex : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.CreateTable(
  13. name: "IndexDailyPrice",
  14. columns: table => new
  15. {
  16. ID = table.Column<long>(type: "bigint", nullable: false)
  17. .Annotation("SqlServer:Identity", "1, 1"),
  18. Series = table.Column<byte>(type: "tinyint", nullable: false, comment: "계열 구분 (1=KOSPI, 2=KOSDAQ, 3=KRX)"),
  19. IndexName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "지수명"),
  20. TradeDate = table.Column<DateOnly>(type: "date", nullable: false),
  21. Close = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "종가"),
  22. ChangeVal = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "전일 대비"),
  23. FlucRateBp = table.Column<int>(type: "int", nullable: false, comment: "등락률 basis point (%×100)"),
  24. Open = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "시가"),
  25. High = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "고가"),
  26. Low = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "저가"),
  27. Volume = table.Column<long>(type: "bigint", nullable: false),
  28. Value = table.Column<long>(type: "bigint", nullable: false, comment: "거래대금 (원)"),
  29. MarketCap = table.Column<long>(type: "bigint", nullable: true, comment: "상장시가총액 (원)"),
  30. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  31. },
  32. constraints: table =>
  33. {
  34. table.PrimaryKey("PK_IndexDailyPrice", x => x.ID);
  35. },
  36. comment: "지수(시장) 일별 마감 시세 (KRX OpenAPI)");
  37. migrationBuilder.CreateIndex(
  38. name: "IX_IndexDailyPrice_Series_IndexName_TradeDate",
  39. table: "IndexDailyPrice",
  40. columns: new[] { "Series", "IndexName", "TradeDate" },
  41. unique: true);
  42. migrationBuilder.CreateIndex(
  43. name: "IX_IndexDailyPrice_TradeDate",
  44. table: "IndexDailyPrice",
  45. column: "TradeDate");
  46. }
  47. /// <inheritdoc />
  48. protected override void Down(MigrationBuilder migrationBuilder)
  49. {
  50. migrationBuilder.DropTable(
  51. name: "IndexDailyPrice");
  52. }
  53. }
  54. }