-- t-paliad-182 down — reverses 078_unified_rule_columns.up.sql.
--
-- Drops in reverse dependency order: indexes → CHECK constraints →
-- FKs → columns. Idempotent (IF EXISTS guards everywhere).

DROP INDEX IF EXISTS paliad.deadline_rules_lifecycle_state_idx;
DROP INDEX IF EXISTS paliad.deadline_rules_spawn_proceeding_type_id_idx;
DROP INDEX IF EXISTS paliad.deadline_rules_trigger_event_id_idx;

ALTER TABLE paliad.deadline_rules DROP CONSTRAINT IF EXISTS deadline_rules_lifecycle_state_check;
ALTER TABLE paliad.deadline_rules DROP CONSTRAINT IF EXISTS deadline_rules_priority_check;
ALTER TABLE paliad.deadline_rules DROP CONSTRAINT IF EXISTS deadline_rules_combine_op_check;

ALTER TABLE paliad.deadline_rules DROP CONSTRAINT IF EXISTS deadline_rules_draft_of_fkey;
ALTER TABLE paliad.deadline_rules DROP CONSTRAINT IF EXISTS deadline_rules_spawn_proceeding_type_id_fkey;
ALTER TABLE paliad.deadline_rules DROP CONSTRAINT IF EXISTS deadline_rules_trigger_event_id_fkey;

ALTER TABLE paliad.deadline_rules
    DROP COLUMN IF EXISTS published_at,
    DROP COLUMN IF EXISTS draft_of,
    DROP COLUMN IF EXISTS lifecycle_state,
    DROP COLUMN IF EXISTS is_court_set,
    DROP COLUMN IF EXISTS priority,
    DROP COLUMN IF EXISTS condition_expr,
    DROP COLUMN IF EXISTS combine_op,
    DROP COLUMN IF EXISTS spawn_proceeding_type_id,
    DROP COLUMN IF EXISTS trigger_event_id;
