20260414190517_AddSettlementAccountAndWithdrawalRequest.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Infrastructure.Migrations.AppDb;
  5. /// <inheritdoc />
  6. public partial class AddSettlementAccountAndWithdrawalRequest : Migration
  7. {
  8. /// <inheritdoc />
  9. protected override void Up(MigrationBuilder migrationBuilder)
  10. {
  11. migrationBuilder.CreateTable(
  12. name: "SettlementAccount",
  13. columns: table => new
  14. {
  15. ID = table.Column<int>(type: "int", nullable: false)
  16. .Annotation("SqlServer:Identity", "1, 1"),
  17. ChannelID = table.Column<int>(type: "int", nullable: false),
  18. MemberID = table.Column<int>(type: "int", nullable: false),
  19. BankCode = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false),
  20. BankName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
  21. AccountNumber = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
  22. AccountHolder = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
  23. IsVerified = table.Column<bool>(type: "bit", nullable: false),
  24. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
  25. UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
  26. },
  27. constraints: table =>
  28. {
  29. table.PrimaryKey("PK_SettlementAccount", x => x.ID);
  30. table.ForeignKey(
  31. name: "FK_SettlementAccount_Channel_ChannelID",
  32. column: x => x.ChannelID,
  33. principalTable: "Channel",
  34. principalColumn: "ID");
  35. table.ForeignKey(
  36. name: "FK_SettlementAccount_Member_MemberID",
  37. column: x => x.MemberID,
  38. principalTable: "Member",
  39. principalColumn: "ID");
  40. },
  41. comment: "정산 계좌");
  42. migrationBuilder.CreateTable(
  43. name: "WithdrawalRequest",
  44. columns: table => new
  45. {
  46. ID = table.Column<int>(type: "int", nullable: false)
  47. .Annotation("SqlServer:Identity", "1, 1"),
  48. ChannelID = table.Column<int>(type: "int", nullable: false),
  49. MemberID = table.Column<int>(type: "int", nullable: false),
  50. RequestedAmount = table.Column<int>(type: "int", nullable: false),
  51. IncomeTax = table.Column<int>(type: "int", nullable: false),
  52. LocalTax = table.Column<int>(type: "int", nullable: false),
  53. WithholdingTax = table.Column<int>(type: "int", nullable: false),
  54. NetAmount = table.Column<int>(type: "int", nullable: false),
  55. Status = table.Column<int>(type: "int", nullable: false),
  56. BankCode = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false),
  57. BankName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
  58. AccountNumber = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
  59. AccountHolder = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
  60. RequestedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
  61. ProcessedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
  62. RejectedReason = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
  63. AdminMemo = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true)
  64. },
  65. constraints: table =>
  66. {
  67. table.PrimaryKey("PK_WithdrawalRequest", x => x.ID);
  68. table.ForeignKey(
  69. name: "FK_WithdrawalRequest_Channel_ChannelID",
  70. column: x => x.ChannelID,
  71. principalTable: "Channel",
  72. principalColumn: "ID");
  73. table.ForeignKey(
  74. name: "FK_WithdrawalRequest_Member_MemberID",
  75. column: x => x.MemberID,
  76. principalTable: "Member",
  77. principalColumn: "ID");
  78. },
  79. comment: "출금 요청");
  80. migrationBuilder.CreateIndex(
  81. name: "IX_SettlementAccount_ChannelID_MemberID",
  82. table: "SettlementAccount",
  83. columns: new[] { "ChannelID", "MemberID" },
  84. unique: true);
  85. migrationBuilder.CreateIndex(
  86. name: "IX_SettlementAccount_MemberID",
  87. table: "SettlementAccount",
  88. column: "MemberID");
  89. migrationBuilder.CreateIndex(
  90. name: "IX_WithdrawalRequest_ChannelID",
  91. table: "WithdrawalRequest",
  92. column: "ChannelID");
  93. migrationBuilder.CreateIndex(
  94. name: "IX_WithdrawalRequest_MemberID_RequestedAt",
  95. table: "WithdrawalRequest",
  96. columns: new[] { "MemberID", "RequestedAt" });
  97. migrationBuilder.CreateIndex(
  98. name: "IX_WithdrawalRequest_MemberID_Status",
  99. table: "WithdrawalRequest",
  100. columns: new[] { "MemberID", "Status" });
  101. }
  102. /// <inheritdoc />
  103. protected override void Down(MigrationBuilder migrationBuilder)
  104. {
  105. migrationBuilder.DropTable(
  106. name: "SettlementAccount");
  107. migrationBuilder.DropTable(
  108. name: "WithdrawalRequest");
  109. }
  110. }