fix(db): drop files_user_id_fkey — anonymous users may not exist in users table
The conversations table has no FK on user_id, but files had one, causing 500 errors on file upload when the anonymous user wasn't registered. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
308dd7798e
commit
06226a3d74
|
|
@ -1604,7 +1604,7 @@ CREATE TABLE files (
|
||||||
-- 租户ID
|
-- 租户ID
|
||||||
tenant_id UUID NOT NULL DEFAULT '00000000-0000-0000-0000-000000000001',
|
tenant_id UUID NOT NULL DEFAULT '00000000-0000-0000-0000-000000000001',
|
||||||
-- 所属用户ID
|
-- 所属用户ID
|
||||||
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
user_id UUID NOT NULL,
|
||||||
-- 关联的对话ID(可选)
|
-- 关联的对话ID(可选)
|
||||||
conversation_id UUID REFERENCES conversations(id) ON DELETE SET NULL,
|
conversation_id UUID REFERENCES conversations(id) ON DELETE SET NULL,
|
||||||
-- 原始文件名
|
-- 原始文件名
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
-- Drop foreign key constraint on files.user_id
|
||||||
|
-- Anonymous users may not exist in users table (conversations also has no FK on user_id)
|
||||||
|
ALTER TABLE files DROP CONSTRAINT IF EXISTS files_user_id_fkey;
|
||||||
Loading…
Reference in New Issue