Phase 3 Slice 1 Step A (design §3.1). Additive only; no drops, no data change. Adds nine columns to paliad.deadline_rules so the calculator + rule editor can converge on a single rule shape over the following slices: trigger_event_id (bigint, FK trigger_events.id) spawn_proceeding_type_id (int, FK proceeding_types.id) combine_op (text, CHECK 'max'|'min') condition_expr (jsonb) priority (text, DEFAULT 'mandatory', 4-way CHECK) is_court_set (bool, DEFAULT false) lifecycle_state (text, DEFAULT 'published', 3-way CHECK) draft_of (uuid, self-FK) published_at (timestamptz) FK types follow the actual referenced columns (bigint on trigger_events, int4 serial on proceeding_types) — the design doc's "int FK" shorthand is widened to the precise widths. FKs are DEFERRABLE INITIALLY IMMEDIATE so Slice 3's data-move can defer FK checks within a single transaction without disturbing normal-statement semantics. Indexes: partial WHERE NOT NULL on the two FK columns (sparse; most rules have neither); plain btree on lifecycle_state so the admin filter on 'published' is O(log n).
28 lines
1.4 KiB
SQL
28 lines
1.4 KiB
SQL
-- 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;
|