20260706044022_AddBondDailyTrade.cs 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Infrastructure.Migrations.AppDb
  5. {
  6. /// <inheritdoc />
  7. public partial class AddBondDailyTrade : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.CreateTable(
  13. name: "BondDailyTrade",
  14. columns: table => new
  15. {
  16. ID = table.Column<long>(type: "bigint", nullable: false)
  17. .Annotation("SqlServer:Identity", "1, 1"),
  18. BondMarket = table.Column<byte>(type: "tinyint", nullable: false, comment: "채권 시장 구분 (1=국채전문유통, 2=일반채권, 3=소액채권)"),
  19. Code = table.Column<string>(type: "nvarchar(12)", maxLength: 12, nullable: false, comment: "단축코드 (ISU_CD) — 12자리 ISIN"),
  20. Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "종목명"),
  21. TradeDate = table.Column<DateOnly>(type: "date", nullable: false),
  22. Close = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "종가 가격 (CLSPRC)"),
  23. Open = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "시가 가격 (OPNPRC)"),
  24. High = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "고가 가격 (HGPRC)"),
  25. Low = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "저가 가격 (LWPRC)"),
  26. ChangeAmount = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "전일 대비 (CMPPREVDD_PRC)"),
  27. YieldToMaturity = table.Column<decimal>(type: "decimal(9,3)", precision: 9, scale: 3, nullable: true, comment: "만기수익률 % (CLSPRC_YD)"),
  28. OpenYield = table.Column<decimal>(type: "decimal(9,3)", precision: 9, scale: 3, nullable: true, comment: "시가 수익률 % (OPNPRC_YD)"),
  29. HighYield = table.Column<decimal>(type: "decimal(9,3)", precision: 9, scale: 3, nullable: true, comment: "고가 수익률 % (HGPRC_YD)"),
  30. LowYield = table.Column<decimal>(type: "decimal(9,3)", precision: 9, scale: 3, nullable: true, comment: "저가 수익률 % (LWPRC_YD)"),
  31. Volume = table.Column<long>(type: "bigint", nullable: false, comment: "거래량 (ACC_TRDVOL)"),
  32. TradeValue = table.Column<long>(type: "bigint", nullable: false, comment: "거래대금 (ACC_TRDVAL, 원)"),
  33. MaturityYears = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true, comment: "만기년수 (국채전문, BND_EXP_TP_NM)"),
  34. IssueType = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true, comment: "종목구분 (국채전문, GOVBND_ISU_TP_NM)"),
  35. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  36. },
  37. constraints: table =>
  38. {
  39. table.PrimaryKey("PK_BondDailyTrade", x => x.ID);
  40. },
  41. comment: "채권(국채전문유통/일반채권/소액채권) 일별매매 시세 (KRX OpenAPI bon)");
  42. migrationBuilder.CreateIndex(
  43. name: "IX_BondDailyTrade_BondMarket_Code_TradeDate",
  44. table: "BondDailyTrade",
  45. columns: new[] { "BondMarket", "Code", "TradeDate" },
  46. unique: true);
  47. migrationBuilder.CreateIndex(
  48. name: "IX_BondDailyTrade_BondMarket_TradeDate_TradeValue",
  49. table: "BondDailyTrade",
  50. columns: new[] { "BondMarket", "TradeDate", "TradeValue" },
  51. descending: new[] { false, false, true });
  52. }
  53. /// <inheritdoc />
  54. protected override void Down(MigrationBuilder migrationBuilder)
  55. {
  56. migrationBuilder.DropTable(
  57. name: "BondDailyTrade");
  58. }
  59. }
  60. }