Skip to content

Implement multi-organization support#19

Merged
emilam merged 5 commits into
mainfrom
emilam/org-multi-account
Mar 12, 2026
Merged

Implement multi-organization support#19
emilam merged 5 commits into
mainfrom
emilam/org-multi-account

Conversation

@emilam

@emilam emilam commented Mar 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add multi-organization data model and org-scoped queries. Users can now create organizations, switch between them, and access org-specific posts and accounts. Introduces org membership tracking, seeding data for multiple organizations, and updates all API routes and UI components to respect organization scope.

Changes

  • Add organizations and organization_members tables with RLS policies
  • Org-scoped queries for posts, Instagram accounts, and Facebook pages
  • New API routes: /org/create, /org/list, /org/switch
  • Update account management and post views to use org context
  • Add org-switcher component in posts page
  • Update seed data with multiple organizations
  • Add TokenLifetimeMs constant to tests for consistency
  • New test suite for organization queries

Test plan

  • Run npm run test:docker to verify all tests pass
  • Sign in as test user and switch between organizations
  • Verify posts/accounts shown are org-scoped
  • Verify new organizations can be created and accessed

🤖 Generated with Claude Code

emilam and others added 2 commits March 11, 2026 16:32
Introduces organizations as the ownership entity for social accounts and
posts. Users belong to orgs via memberships with roles (owner/manager/member).

Key changes:
- Migration 014: organizations + organization_members tables, org-based
  RLS policies, backfill existing data, move connection FK from profile_id
  to organization_id
- Org context via signed JWT cookie (org-context.ts) with switcher UI
- Posts page shows "My Posts" vs "All Posts" filter, always scoped to
  active org
- Core business logic (publish, stats, comments) resolves connections
  from post.organization_id instead of cookie-based org lookup, fixing
  SMS/cron contexts
- New post creation uses LLM to infer target org for multi-org SMS users
- Docker dev environment with volume mounts for hot-reload
- Tests updated for org-scoped data model throughout

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… flows

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Mar 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
postimp Ready Ready Preview, Comment Mar 12, 2026 3:48am

emilam and others added 2 commits March 11, 2026 20:41
Resolve conflict in account-view.tsx: keep org-scoped connection
queries, reauth warnings, and pending Facebook token state.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Migration 014 (from main) added a profile_id-based SELECT policy.
Our org migration drops profile_id, so we need to explicitly drop
that policy and replace it with org-scoped equivalents.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@emilam emilam merged commit c33855f into main Mar 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant