using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Infrastructure.Migrations.AppDb { /// public partial class AddEtpDailyTrade : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "EtpDailyTrade", columns: table => new { ID = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), EtpType = table.Column(type: "tinyint", nullable: false, comment: "증권상품 구분 (1=ETF, 2=ETN, 3=ELW)"), Code = table.Column(type: "nchar(6)", fixedLength: true, maxLength: 6, nullable: false, comment: "단축코드 (ISU_CD)"), 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: "종가"), 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: "저가"), ChangeAmount = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "전일 대비"), ChangeRate = table.Column(type: "decimal(7,2)", precision: 7, scale: 2, nullable: false, comment: "등락률 % (ELW 는 0)"), Volume = table.Column(type: "bigint", nullable: false, comment: "거래량"), TradeValue = table.Column(type: "bigint", nullable: false, comment: "거래대금 (원)"), MarketCap = table.Column(type: "bigint", nullable: true, comment: "시가총액 (원)"), ListedShares = table.Column(type: "bigint", nullable: true, comment: "상장증권수/상장좌수"), Nav = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "ETF NAV / ETN 지표가치(IV)"), NetAssetTotal = table.Column(type: "bigint", nullable: true, comment: "ETF 순자산총액 / ETN 지표가치총액 (원)"), BaseIndexName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "기초지수명 (ETF/ETN)"), BaseIndexClose = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "기초지수 종가 (ETF/ETN)"), Underlying = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "ELW 기초자산명"), UnderlyingClose = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "ELW 기초자산 종가"), CreatedAt = table.Column(type: "datetime2", nullable: false) }, constraints: table => { table.PrimaryKey("PK_EtpDailyTrade", x => x.ID); }, comment: "증권상품(ETF/ETN/ELW) 일별매매 시세 (KRX OpenAPI etp)"); migrationBuilder.CreateIndex( name: "IX_EtpDailyTrade_EtpType_Code_TradeDate", table: "EtpDailyTrade", columns: new[] { "EtpType", "Code", "TradeDate" }, unique: true); migrationBuilder.CreateIndex( name: "IX_EtpDailyTrade_EtpType_TradeDate_TradeValue", table: "EtpDailyTrade", columns: new[] { "EtpType", "TradeDate", "TradeValue" }, descending: new[] { false, false, true }); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "EtpDailyTrade"); } } }