[PR #5011] [CLOSED] fix(organization): activeOrganizationId doesn't use FK #5717

Closed
opened 2026-03-13 12:32:45 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5011
Author: @ping-maxwell
Created: 10/1/2025
Status: Closed

Base: canaryHead: fix/active-org-id-use-reference


📝 Commits (3)

  • 7a69af2 fix(organization): activeOrganizationId doesn't use FK
  • 38bb7a4 chore: cleanup
  • 46d807e Merge branch 'canary' into fix/active-org-id-use-reference

📊 Changes

1 file changed (+7 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/plugins/organization/organization.ts (+7 -1)

📄 Description

Not sure why we don't use references on activeOrganizationId - but this PR implements it.

closes https://github.com/better-auth/better-auth/issues/2606


Summary by cubic

Add a foreign key for session.activeOrganizationId to organization.id. This enforces referential integrity and clears the field when the organization is deleted.

  • Bug Fixes
    • Added references: field "id", model "organization", onDelete "set null".
    • Ensured the field definition satisfies DBFieldAttribute for type safety.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5011 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 10/1/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/active-org-id-use-reference` --- ### 📝 Commits (3) - [`7a69af2`](https://github.com/better-auth/better-auth/commit/7a69af2998ccd83f666a8145e7c038696ce4ad0d) fix(organization): `activeOrganizationId` doesn't use FK - [`38bb7a4`](https://github.com/better-auth/better-auth/commit/38bb7a46161c0b44ae686a4a24fcaf0f558a9cf4) chore: cleanup - [`46d807e`](https://github.com/better-auth/better-auth/commit/46d807e28e211cd48d2aa1c6c5541c2bb8eafb5c) Merge branch 'canary' into fix/active-org-id-use-reference ### 📊 Changes **1 file changed** (+7 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/organization.ts` (+7 -1) </details> ### 📄 Description Not sure why we don't use `references` on `activeOrganizationId` - but this PR implements it. closes https://github.com/better-auth/better-auth/issues/2606 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add a foreign key for session.activeOrganizationId to organization.id. This enforces referential integrity and clears the field when the organization is deleted. - **Bug Fixes** - Added references: field "id", model "organization", onDelete "set null". - Ensured the field definition satisfies DBFieldAttribute for type safety. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:32:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#5717