Goal
The admins table currently has an organization_id column, limiting admins to a single organization. This needs to be refactored so users can belong to multiple organizations.
Scope
Database Migration
- Create a new
organization_users many-to-many table linking admins to organizations with roles (member, admin, owner).
- Backfill
organization_users from existing admins.organization_id data.
- Drop the
organization_id column from the admins table after backfill.
Backend Updates
- Update all backend queries that rely on
admins.organization_id to use the new organization_users table.
- Update the Clerk auth flow — currently auto-provisions a single org on first login. Needs to handle users that already exist across multiple organizations.
OpenFGA Authorization Model
- Update the OpenFGA authorization model and relationship tuples to reflect the new
organization_users structure.
- Ensure RBAC checks work correctly for users belonging to multiple organizations.
Goal
The
adminstable currently has anorganization_idcolumn, limiting admins to a single organization. This needs to be refactored so users can belong to multiple organizations.Scope
Database Migration
organization_usersmany-to-many table linking admins to organizations with roles (member,admin,owner).organization_usersfrom existingadmins.organization_iddata.organization_idcolumn from theadminstable after backfill.Backend Updates
admins.organization_idto use the neworganization_userstable.OpenFGA Authorization Model
organization_usersstructure.