iconsulting/database/migrations/20260207_add_deleted_status...

11 lines
523 B
SQL
Raw Permalink 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.

-- Migration: Add 'DELETED' to conversations status CHECK constraint
-- 修复:软删除功能需要 DELETED 状态,但数据库 CHECK 约束未包含该值
-- 导致用户无法删除历史对话QueryFailedError: conversations_status_check
-- 删除旧约束
ALTER TABLE conversations DROP CONSTRAINT IF EXISTS conversations_status_check;
-- 添加包含 DELETED 的新约束
ALTER TABLE conversations ADD CONSTRAINT conversations_status_check
CHECK (status IN ('ACTIVE', 'ENDED', 'ARCHIVED', 'DELETED'));