using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Infrastructure.Migrations.AppDb { /// public partial class AddMarketIndex : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "IndexDailyPrice", columns: table => new { ID = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Series = table.Column(type: "tinyint", nullable: false, comment: "계열 구분 (1=KOSPI, 2=KOSDAQ, 3=KRX)"), IndexName = 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: "종가"), ChangeVal = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "전일 대비"), FlucRateBp = table.Column(type: "int", nullable: false, comment: "등락률 basis point (%×100)"), Open = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "시가"), High = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "고가"), Low = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "저가"), Volume = table.Column(type: "bigint", nullable: false), Value = table.Column(type: "bigint", nullable: false, comment: "거래대금 (원)"), MarketCap = table.Column(type: "bigint", nullable: true, comment: "상장시가총액 (원)"), CreatedAt = table.Column(type: "datetime2", nullable: false) }, constraints: table => { table.PrimaryKey("PK_IndexDailyPrice", x => x.ID); }, comment: "지수(시장) 일별 마감 시세 (KRX OpenAPI)"); migrationBuilder.CreateIndex( name: "IX_IndexDailyPrice_Series_IndexName_TradeDate", table: "IndexDailyPrice", columns: new[] { "Series", "IndexName", "TradeDate" }, unique: true); migrationBuilder.CreateIndex( name: "IX_IndexDailyPrice_TradeDate", table: "IndexDailyPrice", column: "TradeDate"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "IndexDailyPrice"); } } }