-- ============================================================================
-- Migration 002: Add source-module tracking to payments
-- Needed for Phase 5 (payment gateway integration) so a payment can be
-- traced back to the POS order / ancillary booking / reservation it paid
-- for. Safe to run against a database that already has the Phase 1-4
-- schema; a fresh install running 001_schema.sql already includes these
-- columns and does not need this file.
-- ============================================================================

ALTER TABLE payments
    ADD COLUMN source_module VARCHAR(40) DEFAULT NULL AFTER guest_id,
    ADD COLUMN source_reference_id INT UNSIGNED DEFAULT NULL AFTER source_module,
    ADD INDEX idx_payments_source (source_module, source_reference_id);
