20260706052225_AddEsgData.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Infrastructure.Migrations.AppDb
  5. {
  6. /// <inheritdoc />
  7. public partial class AddEsgData : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.CreateTable(
  13. name: "EsgIndexDailyPrice",
  14. columns: table => new
  15. {
  16. ID = table.Column<long>(type: "bigint", nullable: false)
  17. .Annotation("SqlServer:Identity", "1, 1"),
  18. IndexName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "지수명 (IDX_NM)"),
  19. TradeDate = table.Column<DateOnly>(type: "date", nullable: false),
  20. Close = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "현재가/종가 (CLSPRC_IDX)"),
  21. ChangeVal = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "전일비 (PRV_DD_CMPR)"),
  22. FlucRateBp = table.Column<int>(type: "int", nullable: false, comment: "등락률 basis point (%×100, UPDN_RATE)"),
  23. ConstituentCount = table.Column<int>(type: "int", nullable: false, comment: "구성종목수 (TRD_ISU_CNT)"),
  24. Volume = table.Column<long>(type: "bigint", nullable: false, comment: "거래량 (ACC_TRDVOL, 천주)"),
  25. Value = table.Column<long>(type: "bigint", nullable: false, comment: "거래대금 (ACC_TRDVAL, 백만원)"),
  26. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  27. },
  28. constraints: table =>
  29. {
  30. table.PrimaryKey("PK_EsgIndexDailyPrice", x => x.ID);
  31. },
  32. comment: "ESG 지수 일별시세 (KRX OpenAPI esg/esg_index_info)");
  33. migrationBuilder.CreateTable(
  34. name: "EsgSecurity",
  35. columns: table => new
  36. {
  37. ID = table.Column<long>(type: "bigint", nullable: false)
  38. .Annotation("SqlServer:Identity", "1, 1"),
  39. Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "종목명 (ISU_ABBRV)"),
  40. TradeDate = table.Column<DateOnly>(type: "date", nullable: false),
  41. Close = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "현재가/종가 (TDD_CLSPRC)"),
  42. ChangeAmount = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "전일비 (CMPPREVDD_PRC)"),
  43. ChangeRate = table.Column<decimal>(type: "decimal(9,2)", precision: 9, scale: 2, nullable: false, comment: "등락률 % (FLUC_RT)"),
  44. ListedShares = table.Column<long>(type: "bigint", nullable: false, comment: "상장좌수 (LIST_SHRS)"),
  45. Volume = table.Column<long>(type: "bigint", nullable: false, comment: "거래량(좌) (ACC_TRDVOL)"),
  46. TradeValue = table.Column<long>(type: "bigint", nullable: false, comment: "거래대금(원) (ACC_TRDVAL)"),
  47. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  48. },
  49. constraints: table =>
  50. {
  51. table.PrimaryKey("PK_EsgSecurity", x => x.ID);
  52. },
  53. comment: "ESG 증권상품 일별시세 (KRX OpenAPI esg/esg_etp_info)");
  54. migrationBuilder.CreateTable(
  55. name: "SriBond",
  56. columns: table => new
  57. {
  58. ID = table.Column<long>(type: "bigint", nullable: false)
  59. .Annotation("SqlServer:Identity", "1, 1"),
  60. Code = table.Column<string>(type: "nvarchar(12)", maxLength: 12, nullable: false, comment: "표준코드 (ISU_CD) — 12자리 ISIN"),
  61. TradeDate = table.Column<DateOnly>(type: "date", nullable: false),
  62. IssuerName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "발행기관 (ISUR_NM)"),
  63. SriBondType = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false, comment: "채권종류 (SRI_BND_TP_NM)"),
  64. Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "종목명 (ISU_NM)"),
  65. ListDate = table.Column<DateOnly>(type: "date", nullable: true, comment: "상장일 (LIST_DD)"),
  66. IssueDate = table.Column<DateOnly>(type: "date", nullable: true, comment: "발행일 (ISU_DD)"),
  67. RedemptionDate = table.Column<DateOnly>(type: "date", nullable: true, comment: "상환일 (REDMPT_DD)"),
  68. CouponRate = table.Column<decimal>(type: "decimal(9,5)", precision: 9, scale: 5, nullable: true, comment: "표면이자율 % (ISU_RT)"),
  69. IssueAmount = table.Column<long>(type: "bigint", nullable: false, comment: "발행금액 (ISU_AMT, 원)"),
  70. ListAmount = table.Column<long>(type: "bigint", nullable: false, comment: "상장금액 (LIST_AMT, 원)"),
  71. BondType = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: true, comment: "채권유형 (BND_TP_NM)"),
  72. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  73. },
  74. constraints: table =>
  75. {
  76. table.PrimaryKey("PK_SriBond", x => x.ID);
  77. },
  78. comment: "사회책임투자채권(SRI) 정보 스냅샷 (KRX OpenAPI esg/sri_bond_info)");
  79. migrationBuilder.CreateIndex(
  80. name: "IX_EsgIndexDailyPrice_IndexName_TradeDate",
  81. table: "EsgIndexDailyPrice",
  82. columns: new[] { "IndexName", "TradeDate" },
  83. unique: true);
  84. migrationBuilder.CreateIndex(
  85. name: "IX_EsgIndexDailyPrice_TradeDate",
  86. table: "EsgIndexDailyPrice",
  87. column: "TradeDate");
  88. migrationBuilder.CreateIndex(
  89. name: "IX_EsgSecurity_Name_TradeDate",
  90. table: "EsgSecurity",
  91. columns: new[] { "Name", "TradeDate" },
  92. unique: true);
  93. migrationBuilder.CreateIndex(
  94. name: "IX_EsgSecurity_TradeDate_TradeValue",
  95. table: "EsgSecurity",
  96. columns: new[] { "TradeDate", "TradeValue" },
  97. descending: new[] { false, true });
  98. migrationBuilder.CreateIndex(
  99. name: "IX_SriBond_Code_TradeDate",
  100. table: "SriBond",
  101. columns: new[] { "Code", "TradeDate" },
  102. unique: true);
  103. migrationBuilder.CreateIndex(
  104. name: "IX_SriBond_TradeDate_SriBondType",
  105. table: "SriBond",
  106. columns: new[] { "TradeDate", "SriBondType" });
  107. }
  108. /// <inheritdoc />
  109. protected override void Down(MigrationBuilder migrationBuilder)
  110. {
  111. migrationBuilder.DropTable(
  112. name: "EsgIndexDailyPrice");
  113. migrationBuilder.DropTable(
  114. name: "EsgSecurity");
  115. migrationBuilder.DropTable(
  116. name: "SriBond");
  117. }
  118. }
  119. }