Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(schemas): add user tenantId foreign key constraint #6644

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

simeng-li
Copy link
Contributor

Summary

We have identified a bug where developers can insert cross-tenant users into an organization using the POST /organizations/:id?users API. Previously, there was no constraint to ensure that a user's tenant_id matches the current organization's tenant_id.

To address this issue, we will add a foreign key constraint for the (tenant_id, user_id) in the organization_user_relations table.

Testing

test locally

image

Checklist

  • .changeset
  • unit tests
  • integration tests
  • necessary TSDoc comments

add user tenantId foreign key constraint to the organizatino_user_relations table
Copy link

COMPARE TO master

Total Size Diff 📈 +1.22 KB

Diff by File
Name Diff
packages/schemas/alterations/next-1727597588-add-organization-user-relations-foreign-key.ts 📈 +1019 Bytes
packages/schemas/tables/organization_user_relations.sql 📈 +169 Bytes
packages/schemas/tables/users.sql 📈 +62 Bytes

Copy link

This PR is stale because it has been open 10 for days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the stale label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

1 participant