20260707002136_AddMacroData.cs 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Infrastructure.Migrations.AppDb
  5. {
  6. /// <inheritdoc />
  7. public partial class AddMacroData : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.CreateTable(
  13. name: "ExchangeRate",
  14. columns: table => new
  15. {
  16. ID = table.Column<long>(type: "bigint", nullable: false)
  17. .Annotation("SqlServer:Identity", "1, 1"),
  18. CurrencyUnit = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false, comment: "통화 코드 (cur_unit) — 예: USD, JPY(100)"),
  19. CurrencyName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "통화명 (cur_nm)"),
  20. TradeDate = table.Column<DateOnly>(type: "date", nullable: false),
  21. DealBasRate = table.Column<decimal>(type: "decimal(10,2)", precision: 10, scale: 2, nullable: false, comment: "매매기준율 (deal_bas_r)"),
  22. Ttb = table.Column<decimal>(type: "decimal(10,2)", precision: 10, scale: 2, nullable: true, comment: "전신환 받으실 때 (ttb)"),
  23. Tts = table.Column<decimal>(type: "decimal(10,2)", precision: 10, scale: 2, nullable: true, comment: "전신환 보내실 때 (tts)"),
  24. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  25. },
  26. constraints: table =>
  27. {
  28. table.PrimaryKey("PK_ExchangeRate", x => x.ID);
  29. },
  30. comment: "일별 환율 (한국수출입은행 OpenAPI AP01 현재환율)");
  31. migrationBuilder.CreateTable(
  32. name: "InterestRate",
  33. columns: table => new
  34. {
  35. ID = table.Column<long>(type: "bigint", nullable: false)
  36. .Annotation("SqlServer:Identity", "1, 1"),
  37. RateType = table.Column<byte>(type: "tinyint", nullable: false, comment: "금리 종류 (1=대출금리, 2=국제금리)"),
  38. ItemName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "항목명 (cur_nm 등)"),
  39. TradeDate = table.Column<DateOnly>(type: "date", nullable: false),
  40. Rate = table.Column<decimal>(type: "decimal(9,4)", precision: 9, scale: 4, nullable: true, comment: "금리 % — 미고시 시 null"),
  41. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  42. },
  43. constraints: table =>
  44. {
  45. table.PrimaryKey("PK_InterestRate", x => x.ID);
  46. },
  47. comment: "일별 금리 (한국수출입은행 OpenAPI AP02 대출금리 / AP03 국제금리)");
  48. migrationBuilder.CreateIndex(
  49. name: "IX_ExchangeRate_CurrencyUnit_TradeDate",
  50. table: "ExchangeRate",
  51. columns: new[] { "CurrencyUnit", "TradeDate" },
  52. unique: true);
  53. migrationBuilder.CreateIndex(
  54. name: "IX_ExchangeRate_TradeDate",
  55. table: "ExchangeRate",
  56. column: "TradeDate");
  57. migrationBuilder.CreateIndex(
  58. name: "IX_InterestRate_RateType_ItemName_TradeDate",
  59. table: "InterestRate",
  60. columns: new[] { "RateType", "ItemName", "TradeDate" },
  61. unique: true);
  62. migrationBuilder.CreateIndex(
  63. name: "IX_InterestRate_TradeDate",
  64. table: "InterestRate",
  65. column: "TradeDate");
  66. }
  67. /// <inheritdoc />
  68. protected override void Down(MigrationBuilder migrationBuilder)
  69. {
  70. migrationBuilder.DropTable(
  71. name: "ExchangeRate");
  72. migrationBuilder.DropTable(
  73. name: "InterestRate");
  74. }
  75. }
  76. }