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