feat(api): scope API keys to organization in Electric sync#1458
feat(api): scope API keys to organization in Electric sync#1458saddlepaddle wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughReplaces table-based apikeys filtering with a JSONB metadata fragment in the API's Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Filter apikeys by organizationId from metadata JSON instead of userId, so users only see keys belonging to the active organization.
b265505 to
e83dd8d
Compare
🚀 Preview Deployment🔗 Preview Links
Preview updates automatically with new commits |
Summary
organizationIdextracted from the metadata JSON field instead ofuserIdDetails
The
metadatacolumn already storesorganizationId(set at key creation time via tRPC). This change uses Postgres JSON extraction (metadata::jsonb->>'organizationId') in the Electric WHERE clause to filter server-side, matching the pattern used by all other org-scoped tables.No schema migration needed — uses the existing metadata field.
Test plan
Linear: SUPER-286
Summary by CodeRabbit
New Features
Refactor