-- V82: withdraw_request 에 펌뱅킹 외부연동 결과 추적 컬럼 추가.
--      어댑터(BankTransferAdapter) 호출 결과(거래ID/상태/처리시각)를 저장하기 위함.

ALTER TABLE withdraw_request
    ADD COLUMN IF NOT EXISTS transfer_tx_id   VARCHAR(64),
    ADD COLUMN IF NOT EXISTS transfer_status  VARCHAR(20),
    ADD COLUMN IF NOT EXISTS transfer_at      TIMESTAMP;

COMMENT ON COLUMN withdraw_request.transfer_tx_id  IS '펌뱅킹 외부 거래 ID (멱등키)';
COMMENT ON COLUMN withdraw_request.transfer_status IS 'ACCEPTED/SETTLED/FAILED — BankTransferStatus';
COMMENT ON COLUMN withdraw_request.transfer_at     IS '펌뱅킹 호출/응답 시각';

CREATE INDEX IF NOT EXISTS idx_wr_transfer_status
    ON withdraw_request(transfer_status)
    WHERE transfer_status IS NOT NULL;
