Files
digital-psychology/apps/api/migrations/000033_intervention_outcomes.up.sql
T
jackyu66git 447fb6da16 feat(ECR-032): CrisisCare InterventionOutcome 只读并 Closed
InterventionOutcome catalog (000033) · Loop continuous.
2026-08-08 03:15:30 +08:00

19 lines
775 B
SQL

-- ECR-032 InterventionOutcome (read catalog)
CREATE TABLE IF NOT EXISTS intervention_outcomes (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
code varchar(64) NOT NULL UNIQUE,
title varchar(128) NOT NULL,
outcome varchar(32) NOT NULL CHECK (outcome IN ('helpline_shown','escalated','blocked')),
active boolean NOT NULL DEFAULT true,
system boolean NOT NULL DEFAULT false,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_intervention_outcomes_active ON intervention_outcomes(active);
INSERT INTO intervention_outcomes(code, title, outcome, active, system)
VALUES ('demo_helpline_shown', '示例展示热线结果', 'helpline_shown', true, true)
ON CONFLICT (code) DO NOTHING;