Convert user_id columns from text to uuid with FK constraints
Nine tables in the Mike backend carry `user_id` as plain text, with no referential link to the auth layer. bmersereau's PR converts all of them to the `uuid` type and adds proper foreign keys against `auth.users(id)`, wrapped in a single transaction so the change is all-or-nothing.
The affected tables cover most of the user-owned data model: projects, subfolders, documents, chats, tabular reviews and their chat threads, and the workflow tables including hidden workflows and workflow shares. Running this as one transaction means a non-UUID value in any of those tables will abort the whole migration rather than leaving the schema in a half-converted state. A pre-flight SQL query is included in comments to surface bad rows before you commit.
The cascade behavior is worth reading before you run this. Most tables get standard cascades tying data to the auth identity, but workflows.user_id is ON DELETE SET NULL instead. The reasoning: shared workflows should survive their original owner's account deletion. If your product treats workflows as collaborative artifacts rather than personal ones, that distinction matters.
Rollback script and a post-migration \d verification step are both included. There's also a small vitest suite running five static-analysis tests against the migration file itself, which is less about exercising the database and more about guarding the migration text against inadvertent edits.
Until user_id is a proper uuid with a FK, orphaned rows can accumulate silently and nothing in the data model can rely on referential integrity to the auth table. This PR makes that problem loud rather than quiet.
Spotted something wrong? Or know the PR text has fresher detail than the writeup above?