Fixes #2 — project_id on chat_histories was referencing projects(id) (bigserial) instead of projects(guid) (uuid). Added migration 019 to repair existing deployments and corrected 018 for fresh installs.
12 lines
523 B
SQL
12 lines
523 B
SQL
-- Migration: 019_fix_chat_histories_fk
|
|
-- Fix the project_id foreign key on chat_histories to reference projects(guid)
|
|
-- instead of projects(id). This corrects the initial migration (018) which
|
|
-- used the wrong column — projects.id is a bigserial, projects.guid is the UUID.
|
|
|
|
ALTER TABLE chat_histories
|
|
DROP CONSTRAINT IF EXISTS chat_histories_project_id_fkey;
|
|
|
|
ALTER TABLE chat_histories
|
|
ADD CONSTRAINT chat_histories_project_id_fkey
|
|
FOREIGN KEY (project_id) REFERENCES projects(guid) ON DELETE SET NULL;
|