using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations.AppDb
{
///
public partial class AddCommodityDailyTrade : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CommodityDailyTrade",
columns: table => new
{
ID = table.Column(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CommodityMarket = table.Column(type: "tinyint", nullable: false, comment: "일반상품 시장 구분 (1=석유, 2=금, 3=배출권)"),
Code = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: false, comment: "단축코드 (ISU_CD) — 석유는 OIL_NM(유종구분)"),
Name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "종목명 (ISU_NM) — 석유는 유종구분"),
TradeDate = table.Column(type: "date", nullable: false),
Close = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "종가 (TDD_CLSPRC) — 석유는 가중평균가격_경쟁"),
Open = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "시가 (TDD_OPNPRC) — 석유 0"),
High = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "고가 (TDD_HGPRC) — 석유 0"),
Low = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "저가 (TDD_LWPRC) — 석유 0"),
ChangeAmount = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "전일 대비 (CMPPREVDD_PRC) — 금/배출권만"),
ChangeRate = table.Column(type: "decimal(9,2)", precision: 9, scale: 2, nullable: true, comment: "등락률 % (FLUC_RT) — 금/배출권만"),
WeightedDiscussionPrice = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "가중평균가격_협의 (WT_DIS_AVG_PRC) — 석유만"),
Volume = table.Column(type: "bigint", nullable: false, comment: "거래량 (ACC_TRDVOL)"),
TradeValue = table.Column(type: "bigint", nullable: false, comment: "거래대금 (ACC_TRDVAL, 원)"),
CreatedAt = table.Column(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CommodityDailyTrade", x => x.ID);
},
comment: "일반상품(석유/금/배출권) 일별매매 시세 (KRX OpenAPI gen)");
migrationBuilder.CreateIndex(
name: "IX_CommodityDailyTrade_CommodityMarket_Code_TradeDate",
table: "CommodityDailyTrade",
columns: new[] { "CommodityMarket", "Code", "TradeDate" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_CommodityDailyTrade_CommodityMarket_TradeDate_TradeValue",
table: "CommodityDailyTrade",
columns: new[] { "CommodityMarket", "TradeDate", "TradeValue" },
descending: new[] { false, false, true });
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CommodityDailyTrade");
}
}
}