20260707140205_AddSeibroReviewFixes.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Infrastructure.Migrations.AppDb
  5. {
  6. /// <inheritdoc />
  7. public partial class AddSeibroReviewFixes : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.DropIndex(
  13. name: "IX_ForeignCustodySecurity_StdDt_Isin",
  14. table: "ForeignCustodySecurity");
  15. migrationBuilder.AlterTable(
  16. name: "ForeignCustodySecurity",
  17. comment: "SEIBro 종목별 외화증권 보관현황 (getSecnFrsecCusInfo) — 종목당 국가별 복수 행. UQ(StdDt,Isin,NationCd,SecnTpcd) (리뷰 결함 #3). ForeignIsins seed 시 활성",
  18. oldComment: "SEIBro 종목별 외화증권 보관현황 (getSecnFrsecCusInfo) — 특정 외화종목(ISIN) 보유금액(USD)·보유수량. ForeignIsins seed 시 활성");
  19. migrationBuilder.AlterColumn<string>(
  20. name: "SecnTpcd",
  21. table: "ForeignCustodySecurity",
  22. type: "nvarchar(2)",
  23. maxLength: 2,
  24. nullable: false,
  25. defaultValue: "",
  26. comment: "종목구분코드 (SECN_TPCD) — 71외화주식~78외화수익증권. 자연키",
  27. oldClrType: typeof(string),
  28. oldType: "nvarchar(2)",
  29. oldMaxLength: 2,
  30. oldNullable: true,
  31. oldComment: "종목구분코드 (SECN_TPCD) — 71외화주식~78외화수익증권");
  32. migrationBuilder.AlterColumn<string>(
  33. name: "NationCd",
  34. table: "ForeignCustodySecurity",
  35. type: "nvarchar(2)",
  36. maxLength: 2,
  37. nullable: false,
  38. defaultValue: "",
  39. comment: "국가코드 (NATION_CD) — 자연키(종목당 국가별 복수 행)",
  40. oldClrType: typeof(string),
  41. oldType: "nvarchar(2)",
  42. oldMaxLength: 2,
  43. oldNullable: true,
  44. oldComment: "국가코드 (NATION_CD)");
  45. migrationBuilder.CreateTable(
  46. name: "SeibroFetchMarker",
  47. columns: table => new
  48. {
  49. ID = table.Column<int>(type: "int", nullable: false)
  50. .Annotation("SqlServer:Identity", "1, 1"),
  51. JobKey = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: false, comment: "수집 job 식별자"),
  52. EntityKey = table.Column<string>(type: "nvarchar(60)", maxLength: 60, nullable: false, comment: "대상 키 (ISIN·회사번호 등, 복합키는 구분자 결합)"),
  53. LastCheckedAt = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "마지막 조회 시도 시각 (UTC, 0행 포함)")
  54. },
  55. constraints: table =>
  56. {
  57. table.PrimaryKey("PK_SeibroFetchMarker", x => x.ID);
  58. },
  59. comment: "SEIBro per-키 rolling 조회 시도 마커 (0행 포함) — 리뷰 결함 #1: 정상 0행 재수집·starvation 해소용");
  60. migrationBuilder.CreateTable(
  61. name: "SeibroSweptDate",
  62. columns: table => new
  63. {
  64. ID = table.Column<int>(type: "int", nullable: false)
  65. .Annotation("SqlServer:Identity", "1, 1"),
  66. JobKey = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: false, comment: "수집 job 식별자"),
  67. Date = table.Column<DateOnly>(type: "date", nullable: false, comment: "스윕 대상 날짜 (요청 파라미터 날짜)"),
  68. Discriminator = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false, comment: "스윕 축 구분 (tpcd/kacd/nation 등, 없으면 빈 문자열)"),
  69. SweptAt = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "조회 완료 시각 (UTC, 0행 포함)")
  70. },
  71. constraints: table =>
  72. {
  73. table.PrimaryKey("PK_SeibroSweptDate", x => x.ID);
  74. },
  75. comment: "SEIBro 날짜 스윕 조회 완료 마커 (0행 포함) — 리뷰 결함 #1: 조용한 날 재조회 제거용");
  76. migrationBuilder.CreateIndex(
  77. name: "IX_ForeignCustodySecurity_StdDt_Isin_NationCd_SecnTpcd",
  78. table: "ForeignCustodySecurity",
  79. columns: new[] { "StdDt", "Isin", "NationCd", "SecnTpcd" },
  80. unique: true);
  81. migrationBuilder.CreateIndex(
  82. name: "IX_SeibroFetchMarker_JobKey_EntityKey",
  83. table: "SeibroFetchMarker",
  84. columns: new[] { "JobKey", "EntityKey" },
  85. unique: true);
  86. migrationBuilder.CreateIndex(
  87. name: "IX_SeibroFetchMarker_JobKey_LastCheckedAt",
  88. table: "SeibroFetchMarker",
  89. columns: new[] { "JobKey", "LastCheckedAt" });
  90. migrationBuilder.CreateIndex(
  91. name: "IX_SeibroSweptDate_JobKey_Date_Discriminator",
  92. table: "SeibroSweptDate",
  93. columns: new[] { "JobKey", "Date", "Discriminator" },
  94. unique: true);
  95. }
  96. /// <inheritdoc />
  97. protected override void Down(MigrationBuilder migrationBuilder)
  98. {
  99. migrationBuilder.DropTable(
  100. name: "SeibroFetchMarker");
  101. migrationBuilder.DropTable(
  102. name: "SeibroSweptDate");
  103. migrationBuilder.DropIndex(
  104. name: "IX_ForeignCustodySecurity_StdDt_Isin_NationCd_SecnTpcd",
  105. table: "ForeignCustodySecurity");
  106. migrationBuilder.AlterTable(
  107. name: "ForeignCustodySecurity",
  108. comment: "SEIBro 종목별 외화증권 보관현황 (getSecnFrsecCusInfo) — 특정 외화종목(ISIN) 보유금액(USD)·보유수량. ForeignIsins seed 시 활성",
  109. oldComment: "SEIBro 종목별 외화증권 보관현황 (getSecnFrsecCusInfo) — 종목당 국가별 복수 행. UQ(StdDt,Isin,NationCd,SecnTpcd) (리뷰 결함 #3). ForeignIsins seed 시 활성");
  110. migrationBuilder.AlterColumn<string>(
  111. name: "SecnTpcd",
  112. table: "ForeignCustodySecurity",
  113. type: "nvarchar(2)",
  114. maxLength: 2,
  115. nullable: true,
  116. comment: "종목구분코드 (SECN_TPCD) — 71외화주식~78외화수익증권",
  117. oldClrType: typeof(string),
  118. oldType: "nvarchar(2)",
  119. oldMaxLength: 2,
  120. oldComment: "종목구분코드 (SECN_TPCD) — 71외화주식~78외화수익증권. 자연키");
  121. migrationBuilder.AlterColumn<string>(
  122. name: "NationCd",
  123. table: "ForeignCustodySecurity",
  124. type: "nvarchar(2)",
  125. maxLength: 2,
  126. nullable: true,
  127. comment: "국가코드 (NATION_CD)",
  128. oldClrType: typeof(string),
  129. oldType: "nvarchar(2)",
  130. oldMaxLength: 2,
  131. oldComment: "국가코드 (NATION_CD) — 자연키(종목당 국가별 복수 행)");
  132. migrationBuilder.CreateIndex(
  133. name: "IX_ForeignCustodySecurity_StdDt_Isin",
  134. table: "ForeignCustodySecurity",
  135. columns: new[] { "StdDt", "Isin" },
  136. unique: true);
  137. }
  138. }
  139. }