fix: migration to convert user_id text → uuid with FK to auth.users
From the PR description
Summary
- Adds
backend/migrations/20260513_userid_text_to_uuid.sql- a transactional migration that convertsuser_id textcolumns touuidand addsREFERENCES auth.users(id)FK constraints on all 9 affected tables workflows.user_idusesON DELETE SET NULL(not CASCADE) to preserve shared workflows when the owner account is deleted- Provides a pre-flight check query (in comments) to identify any non-UUID values before applying
- Adds rollback script
20260513_userid_text_to_uuid.rollback.sql
Closes #104 Closes #114
Affected tables
projects, project_subfolders, documents, chats, tabular_reviews, tabular_review_chats, workflows, hidden_workflows, workflow_shares
Changes
backend/migrations/20260513_userid_text_to_uuid.sql- the migration (wrapped inBEGIN/COMMIT)backend/migrations/20260513_userid_text_to_uuid.rollback.sql- rollback scriptbackend/src/lib/__tests__/useridMigration.test.ts- 5 static analysis testsbackend/package.json-"test": "vitest run"script added
⚠️ Apply instructions
- Run the pre-flight check query from the migration comments - confirm zero rows returned
- Apply via Supabase dashboard SQL editor or
psql - Verify with
\d public.projectsthatuser_idshows typeuuidand a FK constraint
Test plan
- Unit tests added and passing (5/5)
- Backend build passes
Our analysis
Convert user_id columns from text to uuid with FK constraints — read the full analysis →
Think the analysis missed something the PR description covers?
Capture this PR into my fork
Download a Markdown prompt that tells Claude how to port every
commit in this PR into your working tree. Run it via
claude -p < capture-pull-113.md from
inside the repo you want the changes in.