Files

22 lines
1.2 KiB
PL/PgSQL
Raw Permalink Normal View History

BEGIN;
-- Rollback must never silently discard stories already reviewed by a family.
DO $$ BEGIN
IF EXISTS(SELECT 1 FROM story_draft WHERE call_session_id IS NOT NULL) THEN
RAISE EXCEPTION 'Direct-call stories exist; preserve them before rolling back migration 75';
END IF;
END $$;
DROP TRIGGER call_story_consent_changed ON consent_record;
DROP FUNCTION call_story_consent_changed();
DROP FUNCTION call_story_available(uuid);
DROP FUNCTION call_story_authorized(uuid);
DROP TABLE call_story_extraction;
ALTER TABLE story_source DROP CONSTRAINT story_call_utterance_fk, DROP CONSTRAINT story_source_origin_check, DROP CONSTRAINT story_call_source_key;
DROP INDEX story_source_call_idx;
ALTER TABLE story_source DROP COLUMN call_session_id, DROP COLUMN call_utterance_id, DROP COLUMN call_source_revision;
ALTER TABLE story_source ALTER COLUMN conversation_turn_id SET NOT NULL;
ALTER TABLE story_draft DROP CONSTRAINT story_call_scope_fk, DROP CONSTRAINT story_origin_check, DROP CONSTRAINT story_call_generation_key;
ALTER TABLE story_draft DROP COLUMN call_session_id, DROP COLUMN call_privacy_epoch;
ALTER TABLE story_draft ALTER COLUMN conversation_id SET NOT NULL;
ALTER TABLE call_session DROP CONSTRAINT call_session_story_scope;
COMMIT;