Files
story/migrations/000075_direct_call_stories.down.sql
Codex Local bf1233d5df
ci / verify (push) Canceled after 0s
feat: expand companion platform, device controls, and memoir workflows
Add customer and operator login, BLE provisioning, device fleet controls, call memory, memoir generation, and refreshed family and maintenance portals. Include API contracts, migrations, firmware sources, tests, assets, and deployment documentation.
2026-10-08 10:06:44 +08:00

22 lines
1.2 KiB
PL/PgSQL

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;