Files
digital-psychology/apps/api/migrations/000021_ask_quality_feedback.up.sql
T
jackyu66gitandCursor 93227d3316 feat(ECR-020): QualityFeedback 问答质量反馈并 Closed
新增 ask_quality_feedback、运营/C端评分 API 与 admin-h5 问答反馈区;禁改消息/UGC/真支付。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-07 23:02:13 +08:00

24 lines
970 B
SQL

-- ECR-020 QualityFeedback
CREATE TABLE IF NOT EXISTS ask_quality_feedback (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
thread_id uuid NOT NULL REFERENCES ask_threads(id),
message_id uuid NULL REFERENCES ask_messages(id),
source varchar(16) NOT NULL CHECK (source IN ('admin','user')),
rating smallint NOT NULL CHECK (rating >= 1 AND rating <= 5),
tag varchar(32) NULL CHECK (tag IS NULL OR tag IN ('helpful','off_topic','unsafe','other')),
note text NULL,
created_by_admin uuid NULL REFERENCES admin_accounts(id),
created_by_user uuid NULL REFERENCES users(id),
created_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_ask_qf_thread ON ask_quality_feedback(thread_id);
CREATE INDEX IF NOT EXISTS idx_ask_qf_created ON ask_quality_feedback(created_at DESC);
INSERT INTO admin_role_permissions(role_id, code)
SELECT r.id, 'admin.ask.feedback.write'
FROM admin_roles r
WHERE r.name = 'super_admin'
ON CONFLICT DO NOTHING;