-- ================================================
-- Migration: Online-session activation source
-- Date: 2026-07-21
-- Records WHICH action last changed a session extension row's
-- activation_status: a manual admin/RM/Shoba toggle (active/inactive), or the
-- registration lifecycle cascade (archived/cancelled/deleted) when the parent
-- registration is archived/cancelled/soft-deleted. Null until any action has
-- ever been taken on the row. activation_status itself stays a plain
-- active/inactive flag regardless of cause — this column carries the "why".
-- Safe to re-run (IF NOT EXISTS).
-- ================================================

ALTER TABLE hdb_program_registration_online_session
  ADD COLUMN IF NOT EXISTS activation_source VARCHAR(20) NULL;

COMMENT ON COLUMN hdb_program_registration_online_session.activation_source IS
  'Which action last set activation_status: active/inactive (manual toggle) or archived/cancelled/deleted (registration lifecycle cascade). Null until any action has been taken.';

-- Verification
SELECT column_name, data_type, is_nullable, column_default
FROM information_schema.columns
WHERE table_name = 'hdb_program_registration_online_session'
  AND column_name = 'activation_source';
