-- Migration 095: Add deferred until case/status to sag_sager
-- Dato: 3. februar 2026

ALTER TABLE sag_sager
    ADD COLUMN IF NOT EXISTS deferred_until_case_id INTEGER REFERENCES sag_sager(id) ON DELETE SET NULL;

ALTER TABLE sag_sager
    ADD COLUMN IF NOT EXISTS deferred_until_status VARCHAR;

CREATE INDEX IF NOT EXISTS idx_sag_sager_deferred_case
    ON sag_sager(deferred_until_case_id)
    WHERE deleted_at IS NULL;
