-- Reversal of 0007_pipeline_stages_v2.sql (manual; .down files are never auto-applied).
--
-- BEST-EFFORT: the 6->4 stage collapse is lossy and cannot be perfectly inverted (the
-- pattern other .down files here share -- e.g. 0005 cannot DROP COLUMN on old SQLite). It
-- restores VALID legacy 6-stage values, choosing a representative for each collapsed pair:
--   engaged    was outreach OR meeting  -> 'meeting'        (representative)
--   diligence  -> 'due_diligence'                            (exact)
--   commitment was committed OR funded  -> 'committed'      (representative)
-- Opportunities archived from the stray 'lost' value still carry stage = 'lost' but cannot be
-- re-identified as "archived by this migration" vs archived for other reasons, so they are
-- left archived; un-archive (clear deleted_at) manually if a rollback truly needs them back.
UPDATE opportunities SET stage = 'meeting'        WHERE stage = 'engaged';
UPDATE opportunities SET stage = 'due_diligence'  WHERE stage = 'diligence';
UPDATE opportunities SET stage = 'committed'      WHERE stage = 'commitment';
