[PR #5822] [MERGED] docs: fix incorrect unique constraint on subscription.referenceId #6252

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5822
Author: @GautamBytes
Created: 11/7/2025
Status: Merged
Merged: 11/8/2025
Merged by: @Bekacru

Base: canaryHead: fix/stripe-docs-unique-constraint


📝 Commits (1)

  • f0bd57a docs(stripe): Fix incorrect unique constraint on referenceId

📊 Changes

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

View changed files

📝 docs/content/docs/plugins/stripe.mdx (+2 -2)

📄 Description

Summary

This PR fixes a documentation error that causes users to create a buggy database schema, leading to the "duplicate key error" reported in #5781.

The issue is not in the plugin's code (which works correctly), but in the documentation that misleads users into adding an incorrect unique constraint.

The Problem

  1. User's Bug: Issue #5781 reports a "duplicate key error" when users try to resubscribe after cancellation. This only happens if their database has a UNIQUE constraint on referenceId.

  2. Documentation Error: Our docs (docs/content/docs/plugins/stripe.mdx, line 617) incorrectly state:

    { 
      name: "referenceId", 
      isUnique: true  // ❌ WRONG - causes users to add unique constraint
    }
    
    
    

Actual Code: The plugin's schema (packages/stripe/src/schema.ts) correctly does NOT specify unique: true.

Result: Users (especially those using Mongoose or manual schema creation) follow the documentation and add a unique constraint, which breaks the resubscription flow.

The Fix
Update documentation to match the actual implementation:

Change isUnique: true → isUnique: false
Add clear warning: "This should NOT be a unique field in your database, as it must allow users to resubscribe after a cancellation."


Summary by cubic

Corrected Stripe plugin docs: subscription.referenceId is not unique. This prevents users from adding a bad unique constraint that causes duplicate key errors on resubscribe.

Written for commit f0bd57a0cc. Summary will update automatically on new commits.


🔄 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/5822 **Author:** [@GautamBytes](https://github.com/GautamBytes) **Created:** 11/7/2025 **Status:** ✅ Merged **Merged:** 11/8/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/stripe-docs-unique-constraint` --- ### 📝 Commits (1) - [`f0bd57a`](https://github.com/better-auth/better-auth/commit/f0bd57a0cc4ee47af7fb752c18039f34a83dc935) docs(stripe): Fix incorrect unique constraint on referenceId ### 📊 Changes **1 file changed** (+2 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/stripe.mdx` (+2 -2) </details> ### 📄 Description ## Summary This PR fixes a documentation error that causes users to create a buggy database schema, leading to the "duplicate key error" reported in #5781. **The issue is not in the plugin's code** (which works correctly), but in the **documentation** that misleads users into adding an incorrect unique constraint. ## The Problem 1. **User's Bug:** Issue #5781 reports a "duplicate key error" when users try to resubscribe after cancellation. This only happens if their database has a `UNIQUE` constraint on `referenceId`. 2. **Documentation Error:** Our docs (`docs/content/docs/plugins/stripe.mdx`, line 617) incorrectly state: ```markdown { name: "referenceId", isUnique: true // ❌ WRONG - causes users to add unique constraint } Actual Code: The plugin's schema (packages/stripe/src/schema.ts) correctly does NOT specify unique: true. Result: Users (especially those using Mongoose or manual schema creation) follow the documentation and add a unique constraint, which breaks the resubscription flow. **The Fix** Update documentation to match the actual implementation: Change isUnique: true → isUnique: false Add clear warning: "This should NOT be a unique field in your database, as it must allow users to resubscribe after a cancellation." <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Corrected Stripe plugin docs: subscription.referenceId is not unique. This prevents users from adding a bad unique constraint that causes duplicate key errors on resubscribe. <sup>Written for commit f0bd57a0cc4ee47af7fb752c18039f34a83dc935. Summary will update automatically on new commits.</sup> <!-- 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:52:28 -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#6252