Files
CamTalk/fix_user_scenarios.sql

27 lines
1004 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 快速修复脚本:修复 user_scenarios 表约束
-- 在生产 PostgreSQL 容器中执行此文件
-- 1. 允许 description 为空
ALTER TABLE user_scenarios
ALTER COLUMN description DROP NOT NULL;
-- 2. 修复 prompt 长度约束(从 50 改为 10与代码一致
ALTER TABLE user_scenarios
DROP CONSTRAINT IF EXISTS check_prompt_length;
ALTER TABLE user_scenarios
ADD CONSTRAINT check_prompt_length CHECK (char_length(prompt) >= 10 AND char_length(prompt) <= 2000);
-- 更新注释
COMMENT ON COLUMN user_scenarios.description IS '简短描述,可选,显示在情景卡片上(允许为空)';
COMMENT ON COLUMN user_scenarios.prompt IS '角色 System Prompt定义 AI 行为10-2000 字符)';
-- 验证修改
SELECT
con.conname AS constraint_name,
pg_get_constraintdef(con.oid) AS constraint_definition
FROM pg_constraint con
JOIN pg_class rel ON rel.oid = con.conrelid
WHERE rel.relname = 'user_scenarios'
AND con.conname = 'check_prompt_length';