| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using System;
- using Microsoft.EntityFrameworkCore.Migrations;
- #nullable disable
- namespace Infrastructure.Migrations.AppDb
- {
- /// <inheritdoc />
- public partial class AddBondDailyTrade : Migration
- {
- /// <inheritdoc />
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "BondDailyTrade",
- columns: table => new
- {
- ID = table.Column<long>(type: "bigint", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- BondMarket = table.Column<byte>(type: "tinyint", nullable: false, comment: "채권 시장 구분 (1=국채전문유통, 2=일반채권, 3=소액채권)"),
- Code = table.Column<string>(type: "nvarchar(12)", maxLength: 12, nullable: false, comment: "단축코드 (ISU_CD) — 12자리 ISIN"),
- Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "종목명"),
- TradeDate = table.Column<DateOnly>(type: "date", nullable: false),
- Close = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "종가 가격 (CLSPRC)"),
- Open = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "시가 가격 (OPNPRC)"),
- High = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "고가 가격 (HGPRC)"),
- Low = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "저가 가격 (LWPRC)"),
- ChangeAmount = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "전일 대비 (CMPPREVDD_PRC)"),
- YieldToMaturity = table.Column<decimal>(type: "decimal(9,3)", precision: 9, scale: 3, nullable: true, comment: "만기수익률 % (CLSPRC_YD)"),
- OpenYield = table.Column<decimal>(type: "decimal(9,3)", precision: 9, scale: 3, nullable: true, comment: "시가 수익률 % (OPNPRC_YD)"),
- HighYield = table.Column<decimal>(type: "decimal(9,3)", precision: 9, scale: 3, nullable: true, comment: "고가 수익률 % (HGPRC_YD)"),
- LowYield = table.Column<decimal>(type: "decimal(9,3)", precision: 9, scale: 3, nullable: true, comment: "저가 수익률 % (LWPRC_YD)"),
- Volume = table.Column<long>(type: "bigint", nullable: false, comment: "거래량 (ACC_TRDVOL)"),
- TradeValue = table.Column<long>(type: "bigint", nullable: false, comment: "거래대금 (ACC_TRDVAL, 원)"),
- MaturityYears = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true, comment: "만기년수 (국채전문, BND_EXP_TP_NM)"),
- IssueType = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true, comment: "종목구분 (국채전문, GOVBND_ISU_TP_NM)"),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_BondDailyTrade", x => x.ID);
- },
- comment: "채권(국채전문유통/일반채권/소액채권) 일별매매 시세 (KRX OpenAPI bon)");
- migrationBuilder.CreateIndex(
- name: "IX_BondDailyTrade_BondMarket_Code_TradeDate",
- table: "BondDailyTrade",
- columns: new[] { "BondMarket", "Code", "TradeDate" },
- unique: true);
- migrationBuilder.CreateIndex(
- name: "IX_BondDailyTrade_BondMarket_TradeDate_TradeValue",
- table: "BondDailyTrade",
- columns: new[] { "BondMarket", "TradeDate", "TradeValue" },
- descending: new[] { false, false, true });
- }
- /// <inheritdoc />
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "BondDailyTrade");
- }
- }
- }
|