using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Infrastructure.Persistence.Migrations { /// public partial class AddPaymentTables : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "MerchantId", table: "PaymentOrder", type: "nvarchar(20)", maxLength: 20, nullable: false, defaultValue: ""); migrationBuilder.AddColumn( name: "OrderName", table: "PaymentOrder", type: "nvarchar(100)", maxLength: 100, nullable: false, defaultValue: ""); migrationBuilder.CreateTable( name: "PaymentCancel", columns: table => new { ID = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), MemberID = table.Column(type: "int", nullable: false), PaymentOrderID = table.Column(type: "int", nullable: false), Method = table.Column(type: "int", nullable: false), TransactionId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), OrderId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), Amount = table.Column(type: "int", nullable: false), MerchantId = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: false), CancelType = table.Column(type: "int", nullable: false), CancelRequester = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), CancelReason = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), ResponseCode = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), ResponseMessage = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), OriginalTransactionId = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), CancelledAmount = table.Column(type: "int", nullable: true), TransDate = table.Column(type: "nvarchar(15)", maxLength: 15, nullable: true), TransTime = table.Column(type: "nvarchar(15)", maxLength: 15, nullable: true), Balance = table.Column(type: "int", nullable: true), RemainedAmount = table.Column(type: "int", nullable: true), ApprovalDateTime = table.Column(type: "nvarchar(15)", maxLength: 15, nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true) }, constraints: table => { table.PrimaryKey("PK_PaymentCancel", x => x.ID); table.ForeignKey( name: "FK_PaymentCancel_Member_MemberID", column: x => x.MemberID, principalTable: "Member", principalColumn: "ID"); table.ForeignKey( name: "FK_PaymentCancel_PaymentOrder_PaymentOrderID", column: x => x.PaymentOrderID, principalTable: "PaymentOrder", principalColumn: "ID"); }, comment: "PG 결제 취소 (요청+응답)"); migrationBuilder.CreateTable( name: "PaymentConfirm", columns: table => new { ID = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), MemberID = table.Column(type: "int", nullable: false), PaymentOrderID = table.Column(type: "int", nullable: false), Method = table.Column(type: "int", nullable: false), TransactionId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), OrderId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), Amount = table.Column(type: "int", nullable: false), MerchantId = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: false), CertificateToken = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), ResponseCode = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), ResponseMessage = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), OrderName = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), TotalAmount = table.Column(type: "int", nullable: true), DiscountAmount = table.Column(type: "int", nullable: true), UserName = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), TransDate = table.Column(type: "nvarchar(8)", maxLength: 8, nullable: true), TransTime = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), CardCode = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), CardName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), CardNo = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), InstallmentMonths = table.Column(type: "tinyint", nullable: true), ApproveNo = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), ApprovalDateTime = table.Column(type: "nvarchar(15)", maxLength: 15, nullable: true), AuthKey = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), AccountNumber = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), BankCode = table.Column(type: "nvarchar(3)", maxLength: 3, nullable: true), UserId = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), UserEmail = table.Column(type: "nvarchar(60)", maxLength: 60, nullable: true), BankName = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true), ExpireDate = table.Column(type: "nvarchar(10)", maxLength: 10, nullable: true), ExpireTime = table.Column(type: "nvarchar(15)", maxLength: 15, nullable: true), VirtualAccountNumber = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: true), UseCashReceipt = table.Column(type: "nvarchar(1)", maxLength: 1, nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: false), UpdatedAt = table.Column(type: "datetime2", nullable: true) }, constraints: table => { table.PrimaryKey("PK_PaymentConfirm", x => x.ID); table.ForeignKey( name: "FK_PaymentConfirm_Member_MemberID", column: x => x.MemberID, principalTable: "Member", principalColumn: "ID"); table.ForeignKey( name: "FK_PaymentConfirm_PaymentOrder_PaymentOrderID", column: x => x.PaymentOrderID, principalTable: "PaymentOrder", principalColumn: "ID"); }, comment: "PG 결제 승인 (요청+응답)"); migrationBuilder.CreateTable( name: "PaymentLog", columns: table => new { ID = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), MemberID = table.Column(type: "int", nullable: false), LogType = table.Column(type: "int", nullable: false), Code = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: false), Message = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false), TransactionId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), OrderId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), ExtraData = table.Column(type: "nvarchar(4000)", maxLength: 4000, nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: false) }, constraints: table => { table.PrimaryKey("PK_PaymentLog", x => x.ID); table.ForeignKey( name: "FK_PaymentLog_Member_MemberID", column: x => x.MemberID, principalTable: "Member", principalColumn: "ID"); }, comment: "PG 결제 에러/실패/웹훅 로그"); migrationBuilder.CreateIndex( name: "IX_PaymentCancel_CancelType", table: "PaymentCancel", column: "CancelType"); migrationBuilder.CreateIndex( name: "IX_PaymentCancel_MemberID", table: "PaymentCancel", column: "MemberID"); migrationBuilder.CreateIndex( name: "IX_PaymentCancel_Method", table: "PaymentCancel", column: "Method"); migrationBuilder.CreateIndex( name: "IX_PaymentCancel_OrderId", table: "PaymentCancel", column: "OrderId"); migrationBuilder.CreateIndex( name: "IX_PaymentCancel_PaymentOrderID", table: "PaymentCancel", column: "PaymentOrderID"); migrationBuilder.CreateIndex( name: "IX_PaymentCancel_TransactionId", table: "PaymentCancel", column: "TransactionId"); migrationBuilder.CreateIndex( name: "IX_PaymentConfirm_MemberID", table: "PaymentConfirm", column: "MemberID"); migrationBuilder.CreateIndex( name: "IX_PaymentConfirm_Method", table: "PaymentConfirm", column: "Method"); migrationBuilder.CreateIndex( name: "IX_PaymentConfirm_OrderId", table: "PaymentConfirm", column: "OrderId", unique: true); migrationBuilder.CreateIndex( name: "IX_PaymentConfirm_PaymentOrderID", table: "PaymentConfirm", column: "PaymentOrderID"); migrationBuilder.CreateIndex( name: "IX_PaymentConfirm_TransactionId", table: "PaymentConfirm", column: "TransactionId", unique: true); migrationBuilder.CreateIndex( name: "IX_PaymentLog_Code", table: "PaymentLog", column: "Code"); migrationBuilder.CreateIndex( name: "IX_PaymentLog_LogType", table: "PaymentLog", column: "LogType"); migrationBuilder.CreateIndex( name: "IX_PaymentLog_MemberID", table: "PaymentLog", column: "MemberID"); migrationBuilder.CreateIndex( name: "IX_PaymentLog_OrderId", table: "PaymentLog", column: "OrderId"); migrationBuilder.CreateIndex( name: "IX_PaymentLog_TransactionId", table: "PaymentLog", column: "TransactionId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "PaymentCancel"); migrationBuilder.DropTable( name: "PaymentConfirm"); migrationBuilder.DropTable( name: "PaymentLog"); migrationBuilder.DropColumn( name: "MerchantId", table: "PaymentOrder"); migrationBuilder.DropColumn( name: "OrderName", table: "PaymentOrder"); } } }