[PR #4703] [MERGED] fix(api-key): cascade api keys on user deletion #5536

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4703
Author: @ping-maxwell
Created: 9/16/2025
Status: Merged
Merged: 9/16/2025
Merged by: @himself65

Base: canaryHead: fix/api-key-cascade-on-user-delete


📝 Commits (1)

  • 08b1882 fix(api-key): Cascade api keys on user deletion

📊 Changes

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

View changed files

📝 packages/better-auth/src/plugins/api-key/schema.ts (+1 -1)

📄 Description

When a user is about to be deleted, you run into an SQL error saying that the user has a foreign key relation to an API key, thus preventing the user from being deleted. This PR adds an onDelete effect to ensure the api keys are deleted as users get deleted.

https://discord.com/channels/1288403910284935179/1417382336315654267


🔄 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/4703 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 9/16/2025 **Status:** ✅ Merged **Merged:** 9/16/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/api-key-cascade-on-user-delete` --- ### 📝 Commits (1) - [`08b1882`](https://github.com/better-auth/better-auth/commit/08b1882d7523c67ab26cf706cc41d3229973e54a) fix(api-key): Cascade api keys on user deletion ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/api-key/schema.ts` (+1 -1) </details> ### 📄 Description When a user is about to be deleted, you run into an SQL error saying that the user has a foreign key relation to an API key, thus preventing the user from being deleted. This PR adds an `onDelete` effect to ensure the api keys are deleted as users get deleted. https://discord.com/channels/1288403910284935179/1417382336315654267 --- <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:26:21 -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#5536