using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Infrastructure.Migrations.AppDb { /// public partial class AddSeibroReviewFixes : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropIndex( name: "IX_ForeignCustodySecurity_StdDt_Isin", table: "ForeignCustodySecurity"); migrationBuilder.AlterTable( name: "ForeignCustodySecurity", comment: "SEIBro 종목별 외화증권 보관현황 (getSecnFrsecCusInfo) — 종목당 국가별 복수 행. UQ(StdDt,Isin,NationCd,SecnTpcd) (리뷰 결함 #3). ForeignIsins seed 시 활성", oldComment: "SEIBro 종목별 외화증권 보관현황 (getSecnFrsecCusInfo) — 특정 외화종목(ISIN) 보유금액(USD)·보유수량. ForeignIsins seed 시 활성"); migrationBuilder.AlterColumn( name: "SecnTpcd", table: "ForeignCustodySecurity", type: "nvarchar(2)", maxLength: 2, nullable: false, defaultValue: "", comment: "종목구분코드 (SECN_TPCD) — 71외화주식~78외화수익증권. 자연키", oldClrType: typeof(string), oldType: "nvarchar(2)", oldMaxLength: 2, oldNullable: true, oldComment: "종목구분코드 (SECN_TPCD) — 71외화주식~78외화수익증권"); migrationBuilder.AlterColumn( name: "NationCd", table: "ForeignCustodySecurity", type: "nvarchar(2)", maxLength: 2, nullable: false, defaultValue: "", comment: "국가코드 (NATION_CD) — 자연키(종목당 국가별 복수 행)", oldClrType: typeof(string), oldType: "nvarchar(2)", oldMaxLength: 2, oldNullable: true, oldComment: "국가코드 (NATION_CD)"); migrationBuilder.CreateTable( name: "SeibroFetchMarker", columns: table => new { ID = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), JobKey = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: false, comment: "수집 job 식별자"), EntityKey = table.Column(type: "nvarchar(60)", maxLength: 60, nullable: false, comment: "대상 키 (ISIN·회사번호 등, 복합키는 구분자 결합)"), LastCheckedAt = table.Column(type: "datetime2", nullable: false, comment: "마지막 조회 시도 시각 (UTC, 0행 포함)") }, constraints: table => { table.PrimaryKey("PK_SeibroFetchMarker", x => x.ID); }, comment: "SEIBro per-키 rolling 조회 시도 마커 (0행 포함) — 리뷰 결함 #1: 정상 0행 재수집·starvation 해소용"); migrationBuilder.CreateTable( name: "SeibroSweptDate", columns: table => new { ID = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), JobKey = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: false, comment: "수집 job 식별자"), Date = table.Column(type: "date", nullable: false, comment: "스윕 대상 날짜 (요청 파라미터 날짜)"), Discriminator = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: false, comment: "스윕 축 구분 (tpcd/kacd/nation 등, 없으면 빈 문자열)"), SweptAt = table.Column(type: "datetime2", nullable: false, comment: "조회 완료 시각 (UTC, 0행 포함)") }, constraints: table => { table.PrimaryKey("PK_SeibroSweptDate", x => x.ID); }, comment: "SEIBro 날짜 스윕 조회 완료 마커 (0행 포함) — 리뷰 결함 #1: 조용한 날 재조회 제거용"); migrationBuilder.CreateIndex( name: "IX_ForeignCustodySecurity_StdDt_Isin_NationCd_SecnTpcd", table: "ForeignCustodySecurity", columns: new[] { "StdDt", "Isin", "NationCd", "SecnTpcd" }, unique: true); migrationBuilder.CreateIndex( name: "IX_SeibroFetchMarker_JobKey_EntityKey", table: "SeibroFetchMarker", columns: new[] { "JobKey", "EntityKey" }, unique: true); migrationBuilder.CreateIndex( name: "IX_SeibroFetchMarker_JobKey_LastCheckedAt", table: "SeibroFetchMarker", columns: new[] { "JobKey", "LastCheckedAt" }); migrationBuilder.CreateIndex( name: "IX_SeibroSweptDate_JobKey_Date_Discriminator", table: "SeibroSweptDate", columns: new[] { "JobKey", "Date", "Discriminator" }, unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "SeibroFetchMarker"); migrationBuilder.DropTable( name: "SeibroSweptDate"); migrationBuilder.DropIndex( name: "IX_ForeignCustodySecurity_StdDt_Isin_NationCd_SecnTpcd", table: "ForeignCustodySecurity"); migrationBuilder.AlterTable( name: "ForeignCustodySecurity", comment: "SEIBro 종목별 외화증권 보관현황 (getSecnFrsecCusInfo) — 특정 외화종목(ISIN) 보유금액(USD)·보유수량. ForeignIsins seed 시 활성", oldComment: "SEIBro 종목별 외화증권 보관현황 (getSecnFrsecCusInfo) — 종목당 국가별 복수 행. UQ(StdDt,Isin,NationCd,SecnTpcd) (리뷰 결함 #3). ForeignIsins seed 시 활성"); migrationBuilder.AlterColumn( name: "SecnTpcd", table: "ForeignCustodySecurity", type: "nvarchar(2)", maxLength: 2, nullable: true, comment: "종목구분코드 (SECN_TPCD) — 71외화주식~78외화수익증권", oldClrType: typeof(string), oldType: "nvarchar(2)", oldMaxLength: 2, oldComment: "종목구분코드 (SECN_TPCD) — 71외화주식~78외화수익증권. 자연키"); migrationBuilder.AlterColumn( name: "NationCd", table: "ForeignCustodySecurity", type: "nvarchar(2)", maxLength: 2, nullable: true, comment: "국가코드 (NATION_CD)", oldClrType: typeof(string), oldType: "nvarchar(2)", oldMaxLength: 2, oldComment: "국가코드 (NATION_CD) — 자연키(종목당 국가별 복수 행)"); migrationBuilder.CreateIndex( name: "IX_ForeignCustodySecurity_StdDt_Isin", table: "ForeignCustodySecurity", columns: new[] { "StdDt", "Isin" }, unique: true); } } }