20260706041145_AddWarrantDailyTrade.cs 4.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Infrastructure.Migrations.AppDb
  5. {
  6. /// <inheritdoc />
  7. public partial class AddWarrantDailyTrade : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.CreateTable(
  13. name: "WarrantDailyTrade",
  14. columns: table => new
  15. {
  16. ID = table.Column<long>(type: "bigint", nullable: false)
  17. .Annotation("SqlServer:Identity", "1, 1"),
  18. WarrantType = table.Column<byte>(type: "tinyint", nullable: false, comment: "신주인수권 구분 (1=증권, 2=증서)"),
  19. Code = table.Column<string>(type: "nvarchar(12)", maxLength: 12, nullable: false, comment: "단축코드 (ISU_CD) — 8자리 영숫자"),
  20. Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "종목명"),
  21. Market = table.Column<byte>(type: "tinyint", nullable: false, comment: "시장 구분 (1=KOSPI, 2=KOSDAQ, 3=KONEX)"),
  22. TradeDate = table.Column<DateOnly>(type: "date", nullable: false),
  23. Close = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "종가"),
  24. Open = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "시가"),
  25. High = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "고가"),
  26. Low = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "저가"),
  27. ChangeAmount = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, comment: "전일 대비"),
  28. ChangeRate = table.Column<decimal>(type: "decimal(7,2)", precision: 7, scale: 2, nullable: false, comment: "등락률 %"),
  29. Volume = table.Column<long>(type: "bigint", nullable: false, comment: "거래량"),
  30. TradeValue = table.Column<long>(type: "bigint", nullable: false, comment: "거래대금 (원)"),
  31. MarketCap = table.Column<long>(type: "bigint", nullable: true, comment: "시가총액 (원)"),
  32. ListedShares = table.Column<long>(type: "bigint", nullable: true, comment: "상장증권수"),
  33. TargetStockCode = table.Column<string>(type: "nvarchar(6)", maxLength: 6, nullable: true, comment: "대상주식 단축코드 (TARSTK_ISU_SRT_CD)"),
  34. TargetStockName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "대상주식명 (TARSTK_ISU_NM)"),
  35. TargetStockPrice = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "대상주식 현재가 (TARSTK_ISU_PRSNT_PRC)"),
  36. ExercisePrice = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "행사가 (증권, EXER_PRC)"),
  37. ExerciseStartDate = table.Column<DateOnly>(type: "date", nullable: true, comment: "행사 시작일 (증권, EXST_STRT_DD)"),
  38. ExerciseEndDate = table.Column<DateOnly>(type: "date", nullable: true, comment: "행사 종료일 (증권, EXST_END_DD)"),
  39. IssuePrice = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true, comment: "발행가 (증서, ISU_PRC)"),
  40. DelistDate = table.Column<DateOnly>(type: "date", nullable: true, comment: "상장폐지일 (증서, DELIST_DD)"),
  41. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  42. },
  43. constraints: table =>
  44. {
  45. table.PrimaryKey("PK_WarrantDailyTrade", x => x.ID);
  46. },
  47. comment: "신주인수권증권/증서 일별매매 시세 (KRX OpenAPI sto sw/sr)");
  48. migrationBuilder.CreateIndex(
  49. name: "IX_WarrantDailyTrade_WarrantType_Code_TradeDate",
  50. table: "WarrantDailyTrade",
  51. columns: new[] { "WarrantType", "Code", "TradeDate" },
  52. unique: true);
  53. migrationBuilder.CreateIndex(
  54. name: "IX_WarrantDailyTrade_WarrantType_TradeDate_TradeValue",
  55. table: "WarrantDailyTrade",
  56. columns: new[] { "WarrantType", "TradeDate", "TradeValue" },
  57. descending: new[] { false, false, true });
  58. }
  59. /// <inheritdoc />
  60. protected override void Down(MigrationBuilder migrationBuilder)
  61. {
  62. migrationBuilder.DropTable(
  63. name: "WarrantDailyTrade");
  64. }
  65. }
  66. }