-- 決済開始事前通知管理テーブル
CREATE TABLE payment_start_notifications (
    notification_id SERIAL PRIMARY KEY,
    mem_deal_no INTEGER NOT NULL,
    notification_type INTEGER NOT NULL,
    sent_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- 重複送信防止のためのユニークインデックス
CREATE UNIQUE INDEX idx_payment_start_notifications_unique
ON payment_start_notifications(mem_deal_no, notification_type);

-- コメント
COMMENT ON TABLE payment_start_notifications IS '決済開始事前通知履歴';
COMMENT ON COLUMN payment_start_notifications.notification_id IS '通知ID（主キー）';
COMMENT ON COLUMN payment_start_notifications.mem_deal_no IS '会員取引番号（members_deals外部キー）';
COMMENT ON COLUMN payment_start_notifications.notification_type IS '通知種別（1:3ヶ月前, 2:2ヶ月前, 3:1ヶ月前）';
COMMENT ON COLUMN payment_start_notifications.sent_at IS '送信日時';
COMMENT ON COLUMN payment_start_notifications.created_at IS '作成日時';
