[PR #4973] [MERGED] fix(db): onDelete is ignored #5687

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4973
Author: @himself65
Created: 9/29/2025
Status: Merged
Merged: 9/29/2025
Merged by: @himself65

Base: canaryHead: himself65/2025/09/29/fix-schema


📝 Commits (3)

  • 7fd3453 fix(db): onDelete is ignored
  • bc94360 Merge branch 'canary' into himself65/2025/09/29/fix-schema
  • 4514766 Merge branch 'canary' into himself65/2025/09/29/fix-schema

📊 Changes

3 files changed (+74 additions, -2 deletions)

View changed files

📝 packages/better-auth/src/db/get-schema.ts (+1 -0)
📝 packages/better-auth/src/plugins/sso/index.ts (+3 -1)
📝 packages/better-auth/src/plugins/sso/sso.test.ts (+70 -1)

📄 Description

Summary by cubic

Fixes a bug where foreign key onDelete options were ignored in the generated DB schema. SSO providers now persist when the creator user is deleted by setting userId to null.

  • Bug Fixes
    • getSchema now preserves all reference options (including onDelete) by spreading field.references before overriding model and field.
    • SSO schema: userId is optional and references user.id with onDelete: "set null"; SSOProvider.userId type is now optional.
    • Added test to confirm the provider remains and userId becomes null after deleting the creator user.

🔄 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/4973 **Author:** [@himself65](https://github.com/himself65) **Created:** 9/29/2025 **Status:** ✅ Merged **Merged:** 9/29/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/09/29/fix-schema` --- ### 📝 Commits (3) - [`7fd3453`](https://github.com/better-auth/better-auth/commit/7fd3453668cb25018d3d702b2eefc937cd7826ea) fix(db): `onDelete` is ignored - [`bc94360`](https://github.com/better-auth/better-auth/commit/bc94360547e2e822bd2b059d696bd56880c8b7ae) Merge branch 'canary' into himself65/2025/09/29/fix-schema - [`4514766`](https://github.com/better-auth/better-auth/commit/45147665a24b15208d279f18918041ab95094d5a) Merge branch 'canary' into himself65/2025/09/29/fix-schema ### 📊 Changes **3 files changed** (+74 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/db/get-schema.ts` (+1 -0) 📝 `packages/better-auth/src/plugins/sso/index.ts` (+3 -1) 📝 `packages/better-auth/src/plugins/sso/sso.test.ts` (+70 -1) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Fixes a bug where foreign key onDelete options were ignored in the generated DB schema. SSO providers now persist when the creator user is deleted by setting userId to null. - **Bug Fixes** - getSchema now preserves all reference options (including onDelete) by spreading field.references before overriding model and field. - SSO schema: userId is optional and references user.id with onDelete: "set null"; SSOProvider.userId type is now optional. - Added test to confirm the provider remains and userId becomes null after deleting the creator user. <!-- 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:31:48 -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#5687