feat: Phase 1 tenant isolation — add account_id to all tenant tables #133
Reference in New Issue
Block a user
Delete Branch "feat/tenant-isolation-phase-1"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
account_id(tenant boundary) to all 28 tenant tables that lacked it, following the non-negotiable migration sequence: ADD nullable → backfill via JOIN → verify zero NULLs → SET NOT NULL → CREATE INDEXtemplate_treesandplatform_stepsglobal content tables (no account_id, no RLS — readable by all authenticated users)00000000-0000-0000-0000-000000000001) for global content (is_default trees, public steps, global categories/tags)team_idin script tables and target_lists (app code migration deferred)Migrations (10 total, in dependency order)
Gate verification
After merging, run from VPS SSH to confirm zero NULLs across all tenant tables:
Expected output: 0 rows (all tables have zero NULLs).
Known follow-ups
feedback.user_idhasondelete="SET NULL"butnullable=False— pre-existing contradiction, separate fix needed before user deletion path is exercisedTreeTag.is_globalproperty always returns False now (account_id is NOT NULL) — property logic needs updatingcheck_tenant_filters.pyfrom warn to--failmode after app code migration completesapp.current_account_idinget_db()dependency🤖 Generated with Claude Code
🚅 Deployed to the resolutionflow-pr-133 environment in selfless-grace