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