-- 0017 — AuditAction enum extensions for Phase A4 + Phase B action codes
--
-- Adds the new audit action codes I've been firing from the manifest
-- quick-action block (LOAD_HELD, LOAD_RESUMED, LOAD_DELAYED, LOAD_CLOSED,
-- LOAD_REOPENED, LOAD_PILOT_CHANGED, SLOT_MOVED), the owner dropzone
-- registry (OWNER_DZ_*), and the staff-driven waitlist add from Phase 3
-- (WAITLIST_STAFF_ADD). Without these, AuditService.log() silently fails
-- because action values get cast to a strict MySQL ENUM column and the
-- service's try/catch swallows the error, leaving us with no audit
-- trail for these mutations.
--
-- Additive only. Safe to re-run (MySQL drops duplicate enum values at
-- ALTER time, and we detect the column first).

-- MySQL ENUM extensions are done by re-declaring the column with the
-- full value list. This is a metadata-only change; no row data moves.
ALTER TABLE `audit_logs`
  MODIFY COLUMN `action` ENUM(
    'CREATE',
    'UPDATE',
    'DELETE',
    'LOGIN',
    'LOGOUT',
    'PAYMENT',
    'REFUND',
    'ROLE_GRANT',
    'ROLE_REVOKE',
    'INCIDENT_REPORT',
    'GEAR_CHECK',
    'WAIVER_SIGN',
    'LOAD_CREATE',
    'LOAD_CANCEL',
    'LOAD_DEPART',
    'SLOT_ASSIGN',
    'SLOT_CANCEL',
    'EMERGENCY_ACTIVATE',
    'EMERGENCY_DEACTIVATE',
    'LOAD_UPDATE',
    'LOAD_DELETE',
    'LOAD_LOCK',
    'SLOT_CREATE',
    'SLOT_DELETE',
    'MANIFEST_GROUP',
    'PROFILE_UPDATE',
    'CG_CHECK',
    'CG_OVERRIDE',
    'OVERRIDE',
    'BOOKING_CREATE',
    'BOOKING_CANCEL',
    'AFF_EVALUATE',
    'INSTRUCTOR_ASSIGN',
    'GEAR_ASSIGN',
    'REPACK_LOG',
    'LOAD_TRANSITION',
    'SAFETY_OVERRIDE',
    'WAITLIST_ADD',
    'WAITLIST_PROMOTE',
    'EXIT_ORDER_ASSIGN',
    'POLICY_CREATE',
    'POLICY_UPDATE',
    'POLICY_OVERRIDE',
    'VERIFICATION_CREATE',
    'VERIFICATION_UPDATE',
    'DATA_IMPORT',
    'DATA_IMPORT_ROLLBACK',
    'DATA_EXPORT',
    'DEMO_LOAD',
    'DEMO_CLEAR',
    'TENANT_RESET',
    'REGION_CREATE',
    'REGION_UPDATE',
    'REGION_DELETE',
    'FACILITY_CREATE',
    'FACILITY_UPDATE',
    'FACILITY_DELETE',
    'FACILITY_STATUS_CHANGE',
    'ENTITLEMENT_GRANT',
    'ENTITLEMENT_REVOKE',
    'ENTITLEMENT_STATE_CHANGE',
    'IMPERSONATION_START',
    'IMPERSONATION_END',
    'WALLET_TRANSFER',
    'WALLET_TRANSFER_APPROVE',
    'WALLET_TRANSFER_REVERSE',
    'REVIEW_CREATE',
    'REVIEW_MODERATE',
    'REPUTATION_RECALCULATE',
    -- Phase A4 + Phase B + Phase 3 additions
    'LOAD_HELD',
    'LOAD_RESUMED',
    'LOAD_DELAYED',
    'LOAD_CLOSED',
    'LOAD_REOPENED',
    'LOAD_PILOT_CHANGED',
    'SLOT_MOVED',
    'OWNER_DZ_CREATE',
    'OWNER_DZ_UPDATE',
    'OWNER_DZ_HIDE',
    'OWNER_DZ_UNHIDE',
    'OWNER_DZ_FREEZE',
    'OWNER_DZ_UNFREEZE',
    'OWNER_DZ_ARCHIVE',
    'OWNER_DZ_SOFT_DELETE',
    'OWNER_DZ_MODULES_UPDATE',
    'OWNER_DZ_IMPORT_COMMIT',
    'WAITLIST_STAFF_ADD'
  ) NOT NULL;
