[PR #5476] [MERGED] fix(organization): correct migration order when dynamicAccessControl is enabled #6026

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5476
Author: @AntonVishal
Created: 10/22/2025
Status: Merged
Merged: 10/24/2025
Merged by: @Bekacru

Base: canaryHead: fix/org-migration-order


📝 Commits (8)

  • 9a23094 fix(organization): Certain parameters not showing in client types (#5214)
  • bce6aec Merge branch 'better-auth:canary' into canary
  • d79abad fix(organization): fix incorrect migration order
  • 44a298c chore: empty commit
  • f6a18ce Clean up postcss.config.mjs
  • a1d9e50 Merge branch 'canary' into fix/org-migration-order
  • 4d8373a refactor: simplify postcss.config.mjs by removing unnecessary imports
  • 36ded2b Merge branch 'canary' into fix/org-migration-order

📊 Changes

2 files changed (+23 additions, -2 deletions)

View changed files

📝 packages/better-auth/src/plugins/organization/organization.test.ts (+19 -0)
📝 packages/better-auth/src/plugins/organization/organization.ts (+4 -2)

📄 Description

Fixed migration order bug in organization plugin. When dynamicAccessControl was enabled, the organizationRole table tried to reference organization before it existed, breaking migrations. Reordered the schema so organization comes first, then the tables that depend on it.

Fixes: https://github.com/better-auth/better-auth/issues/5473


Summary by cubic

Fixes migration failures in the organization plugin by ensuring the organization table is created before dependent tables when dynamicAccessControl is enabled. Prevents foreign key errors and aligns schema order with expected migrations. Fixes #5473.

  • Bug Fixes
    • Reordered schema: organization now precedes organizationRole and team.
    • Added test to validate table order when dynamicAccessControl is enabled.

🔄 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/5476 **Author:** [@AntonVishal](https://github.com/AntonVishal) **Created:** 10/22/2025 **Status:** ✅ Merged **Merged:** 10/24/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/org-migration-order` --- ### 📝 Commits (8) - [`9a23094`](https://github.com/better-auth/better-auth/commit/9a230944f1abf951b1e05c44d3ba729b9f9d2df9) fix(organization): Certain parameters not showing in client types (#5214) - [`bce6aec`](https://github.com/better-auth/better-auth/commit/bce6aec2c33dc4eb71706bf199fdde1792dc24eb) Merge branch 'better-auth:canary' into canary - [`d79abad`](https://github.com/better-auth/better-auth/commit/d79abad0ea5b0550c6d8e0be9ee91bda84877a9f) fix(organization): fix incorrect migration order - [`44a298c`](https://github.com/better-auth/better-auth/commit/44a298c4ed4a0e5c488b822a01e60652c727fa47) chore: empty commit - [`f6a18ce`](https://github.com/better-auth/better-auth/commit/f6a18cecc847f1e09ce6bf5b355c0f9b957a2ccb) Clean up postcss.config.mjs - [`a1d9e50`](https://github.com/better-auth/better-auth/commit/a1d9e506e8277c30ae55127e38f1d1b5c4147b3d) Merge branch 'canary' into fix/org-migration-order - [`4d8373a`](https://github.com/better-auth/better-auth/commit/4d8373aa2673f0f83ee564feb533f6653fa369ff) refactor: simplify postcss.config.mjs by removing unnecessary imports - [`36ded2b`](https://github.com/better-auth/better-auth/commit/36ded2bd7a1849b6c229bbe63a1421eafa83c7f8) Merge branch 'canary' into fix/org-migration-order ### 📊 Changes **2 files changed** (+23 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/organization.test.ts` (+19 -0) 📝 `packages/better-auth/src/plugins/organization/organization.ts` (+4 -2) </details> ### 📄 Description Fixed migration order bug in organization plugin. When dynamicAccessControl was enabled, the organizationRole table tried to reference organization before it existed, breaking migrations. Reordered the schema so organization comes first, then the tables that depend on it. Fixes: https://github.com/better-auth/better-auth/issues/5473 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes migration failures in the organization plugin by ensuring the organization table is created before dependent tables when dynamicAccessControl is enabled. Prevents foreign key errors and aligns schema order with expected migrations. Fixes #5473. - **Bug Fixes** - Reordered schema: organization now precedes organizationRole and team. - Added test to validate table order when dynamicAccessControl is enabled. <!-- 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:44:59 -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#6026