Files
digital-psychology/apps/api/migrations/000024_ask_quality_feedback.up.sql
T
jackyu66gitandCursor b7b0b18802 fix(db): 重编号合并后撞号 migration,并修 admin e2e base
将 015–023 双文件冲突线性化为 015–050;提供已有库 schema_migrations 修复脚本;admin Playwright 对齐 /psy/admin/ 预览路径。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-13 02:14:52 +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;