Subscription schema not generated during generation with Stripe plugin #1730

Closed
opened 2026-03-13 08:59:11 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @cesconix on GitHub (Aug 17, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

When running schema generation with the Stripe plugin enabled, only the stripeCustomerId property is added to the users table. The subscription table is not automatically generated and must be created manually.

Current vs. Expected behavior

I think that the schema generation should create all necessary tables for the Stripe plugin, including the subscription table, to support full Stripe integration functionality.

Current Behavior

  • Users table gets stripeCustomerId field added
  • Subscription table is not generated automatically
  • Must manually create subscription table schema

What version of Better Auth are you using?

1.3.5

System info

System:
  OS: macOS 15.5
  CPU: (10) arm64 Apple M2 Pro
  Memory: 122.50 MB / 16.00 GB
  Shell: 5.9 - /bin/zsh
Browsers:
  Chrome: 139.0.7258.128
  Safari: 18.5

Which area(s) are affected? (Select all that apply)

Database Schema Generation

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { organization } from "better-auth/plugins";
import { stripe } from "@better-auth/stripe";
import Stripe from "stripe";
import { drizzleAdapter } from "better-auth/adapters/drizzle"
import { connectDb } from "../db/index.js"
import * as schema from "../db/schema.js"

const stripeClient = new Stripe("API_KEY", {
  apiVersion: "2025-07-30.basil",
  typescript: true,
});

export const auth = betterAuth({
  database: drizzleAdapter(connectDb(), {
    provider: "pg",
    schema
  }),
  plugins: [
    organization(),
    stripe({
      stripeClient,
      stripeWebhookSecret: "asc",
      createCustomerOnSignUp: true,
    }),
  ],
});

Additional context

All other better-auth functionality works correctly with ES modules.

Originally created by @cesconix on GitHub (Aug 17, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce When running schema generation with the Stripe plugin enabled, only the `stripeCustomerId` property is added to the users table. The `subscription` table is not automatically generated and must be created manually. ### Current vs. Expected behavior I think that the schema generation should create all necessary tables for the Stripe plugin, including the subscription table, to support full Stripe integration functionality. ## Current Behavior - ✅ Users table gets `stripeCustomerId` field added - ❌ Subscription table is not generated automatically - ❌ Must manually create subscription table schema ### What version of Better Auth are you using? 1.3.5 ### System info ```bash System: OS: macOS 15.5 CPU: (10) arm64 Apple M2 Pro Memory: 122.50 MB / 16.00 GB Shell: 5.9 - /bin/zsh Browsers: Chrome: 139.0.7258.128 Safari: 18.5 ``` ### Which area(s) are affected? (Select all that apply) Database Schema Generation ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { organization } from "better-auth/plugins"; import { stripe } from "@better-auth/stripe"; import Stripe from "stripe"; import { drizzleAdapter } from "better-auth/adapters/drizzle" import { connectDb } from "../db/index.js" import * as schema from "../db/schema.js" const stripeClient = new Stripe("API_KEY", { apiVersion: "2025-07-30.basil", typescript: true, }); export const auth = betterAuth({ database: drizzleAdapter(connectDb(), { provider: "pg", schema }), plugins: [ organization(), stripe({ stripeClient, stripeWebhookSecret: "asc", createCustomerOnSignUp: true, }), ], }); ``` ### Additional context All other better-auth functionality works correctly with ES modules.
GiteaMirror added the plugin label 2026-03-13 08:59:11 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 17, 2025):

This is expected: the Stripe plugin currently only adds the stripeCustomerId field to the users table during schema generation. The subscription table is not generated automatically and must be created manually for full Stripe integration. This is a known limitation and has been discussed in several issues and confirmed in the codebase—subscription management endpoints and logic all rely on the subscription table being present, but the plugin does not create it for you (reference, reference).

A typical subscription table schema includes fields like:

  • id (primary key)
  • plan
  • referenceId (user/org ID)
  • stripeCustomerId
  • stripeSubscriptionId
  • status
  • periodStart
  • periodEnd
  • cancelAtPeriodEnd
  • seats
  • trialStart
  • trialEnd
  • updatedAt (recommended to avoid runtime errors reference)

You’ll need to manually create this table in your database. Keep your schema in sync with plugin updates, as missing fields (like updatedAt) can cause runtime errors. There are no recent changes to automate this process, but it’s a commonly requested feature (reference).

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Aug 17, 2025): <!-- Answer --> This is expected: the Stripe plugin currently only adds the `stripeCustomerId` field to the users table during schema generation. The subscription table is not generated automatically and must be created manually for full Stripe integration. This is a known limitation and has been discussed in several issues and confirmed in the codebase—subscription management endpoints and logic all rely on the subscription table being present, but the plugin does not create it for you ([reference](https://github.com/better-auth/better-auth/issues/1627), [reference](https://github.com/better-auth/better-auth/blob/efa60af1c2d45a735ed397171bfca513b7e202ca/packages/stripe/src/index.ts)). A typical subscription table schema includes fields like: - `id` (primary key) - `plan` - `referenceId` (user/org ID) - `stripeCustomerId` - `stripeSubscriptionId` - `status` - `periodStart` - `periodEnd` - `cancelAtPeriodEnd` - `seats` - `trialStart` - `trialEnd` - `updatedAt` (recommended to avoid runtime errors [reference](https://github.com/better-auth/better-auth/issues/3138)) You’ll need to manually create this table in your database. Keep your schema in sync with plugin updates, as missing fields (like `updatedAt`) can cause runtime errors. There are no recent changes to automate this process, but it’s a commonly requested feature ([reference](https://github.com/better-auth/better-auth/issues/1627)). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/6b080561-9772-478a-ba17-0ed411e6bc65?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/6b080561-9772-478a-ba17-0ed411e6bc65?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/6b080561-9772-478a-ba17-0ed411e6bc65?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/6b080561-9772-478a-ba17-0ed411e6bc65?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/6b080561-9772-478a-ba17-0ed411e6bc65?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/6b080561-9772-478a-ba17-0ed411e6bc65?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/6b080561-9772-478a-ba17-0ed411e6bc65?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/4055)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1730