-- mig 110 (down) — revert 'other' addition to paliad.projects.type
--
-- Coerces any 'other' rows back to 'project' (the historical catch-all)
-- so the narrower CHECK constraint can re-attach. This is a lossy
-- rollback: rows that were genuinely 'other' lose that distinction.

SELECT set_config(
    'paliad.audit_reason',
    'mig 110 (down): revert ''other'' from projects.type CHECK; coerce rows to ''project''',
    true);

UPDATE paliad.projects
   SET type = 'project'
 WHERE type = 'other';

ALTER TABLE paliad.projects
    DROP CONSTRAINT IF EXISTS projects_type_check;
ALTER TABLE paliad.projects
    ADD CONSTRAINT projects_type_check
    CHECK (type IN (
        'client', 'litigation', 'patent', 'case', 'project'
    ));
