[GH-ISSUE #1627] stripe plugin doesnt generate customer table with the drizzle adapter #8842

Closed
opened 2026-04-13 04:04:42 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @yamz8 on GitHub (Mar 2, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1627

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

did not generate to customer table

Current vs. Expected behavior

to get the schema spesified here:

https://www.better-auth.com/docs/plugins/stripe#schema

What version of Better Auth are you using?

1.2.1-beta.6

Provide environment information

"drizzle-orm": "^0.34.0",
"drizzle-kit": "^0.25.0",

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

Package

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

No response

Originally created by @yamz8 on GitHub (Mar 2, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1627 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce did not generate to customer table ### Current vs. Expected behavior to get the schema spesified here: https://www.better-auth.com/docs/plugins/stripe#schema ### What version of Better Auth are you using? 1.2.1-beta.6 ### Provide environment information ```bash "drizzle-orm": "^0.34.0", "drizzle-kit": "^0.25.0", ``` ### Which area(s) are affected? (Select all that apply) Package ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-13 04:04:42 -05:00
Author
Owner

@VexoaXYZ commented on GitHub (Mar 2, 2025):

The issue is caused by the Stripe plugin not being properly specified. Ensuring it's included should resolve the problem.

Example:

plugins: [
    stripe({
        stripeClient,
        stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
        createCustomerOnSignUp: true,
        subscription: {
            enabled: true,
            onSubscriptionCancel: async ({ event, subscription, stripeSubscription, cancellationDetails }) => {
                // Handles subscription cancellations elegantly
            },
            onSubscriptionDeleted: async ({ event, subscription, stripeSubscription }) => {
                // Manages subscription deletions efficiently
            },
            plans: [
                {
                    name: "basic",
                    priceId: "price_1Qy0NpFPuZ6ftAZV8OleFiOO",
                    limits: {
                        projects: 5,
                        storage: 10
                    }
                },
                {
                    name: "pro",
                    priceId: "price_1Qy0O4FPuZ6ftAZVr9TreTyM",
                    limits: {
                        projects: 20,
                        storage: 50
                    }
                }
            ]
        }
    })
]
<!-- gh-comment-id:2692663338 --> @VexoaXYZ commented on GitHub (Mar 2, 2025): > The issue is caused by the Stripe plugin not being properly specified. Ensuring it's included should resolve the problem. **Example:** ```ts plugins: [ stripe({ stripeClient, stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET!, createCustomerOnSignUp: true, subscription: { enabled: true, onSubscriptionCancel: async ({ event, subscription, stripeSubscription, cancellationDetails }) => { // Handles subscription cancellations elegantly }, onSubscriptionDeleted: async ({ event, subscription, stripeSubscription }) => { // Manages subscription deletions efficiently }, plans: [ { name: "basic", priceId: "price_1Qy0NpFPuZ6ftAZV8OleFiOO", limits: { projects: 5, storage: 10 } }, { name: "pro", priceId: "price_1Qy0O4FPuZ6ftAZVr9TreTyM", limits: { projects: 20, storage: 50 } } ] } }) ] ```
Author
Owner

@yamz8 commented on GitHub (Mar 2, 2025):

it didn't solve the problem, it does generate the subscription table , not the customer and the trial column

<!-- gh-comment-id:2692681236 --> @yamz8 commented on GitHub (Mar 2, 2025): it didn't solve the problem, it does generate the subscription table , not the customer and the trial column
Author
Owner

@VexoaXYZ commented on GitHub (Mar 2, 2025):

I don't think you need any of those columns/they're not required. It should all work with how stripe intends.

Test it

<!-- gh-comment-id:2692684163 --> @VexoaXYZ commented on GitHub (Mar 2, 2025): I don't think you need any of those columns/they're not required. It should all work with how stripe intends. Test it
Author
Owner

@Kaseax commented on GitHub (Mar 3, 2025):

you don't need a "customer" table - check the docs here about the schema

<!-- gh-comment-id:2694421874 --> @Kaseax commented on GitHub (Mar 3, 2025): you don't need a "customer" table - check the docs [here](https://www.better-auth.com/docs/plugins/stripe#schema) about the schema
Author
Owner

@akucharczyk commented on GitHub (Mar 22, 2025):

Is there a workaround?

<!-- gh-comment-id:2745060706 --> @akucharczyk commented on GitHub (Mar 22, 2025): Is there a workaround?
Author
Owner

@akucharczyk commented on GitHub (Mar 23, 2025):

As a workaround I just created my own file for drizzle, which seams to work fine.

// stripe.ts
import { integer, boolean, text, timestamp, pgTable } from 'drizzle-orm/pg-core'

// Create the subscription table
export const subscription = pgTable('subscription', {
  id: text('id').primaryKey(),
  plan: text('plan').notNull(),
  referenceId: text('reference_id').notNull(), // User ID or org ID
  stripeCustomerId: text('stripe_customer_id'),
  stripeSubscriptionId: text('stripe_subscription_id'),
  status: text('status').notNull(), // active, canceled, etc.
  periodStart: timestamp('period_start'),
  periodEnd: timestamp('period_end'),
  cancelAtPeriodEnd: boolean('cancel_at_period_end'),
  seats: integer('seats'),
  trialStart: timestamp('trial_start'),
  trialEnd: timestamp('trial_end'),
})

also added to my auth-schema.ts

export const user = pgTable("user", {
  id: text("id").primaryKey(),
  name: text("name").notNull(),
  email: text("email").notNull().unique(),
  emailVerified: boolean("email_verified").notNull(),
  image: text("image"),
  // stripe customer id
  stripeCustomerId: text('stripe_customer_id'),
  createdAt: timestamp("created_at").notNull(),
  updatedAt: timestamp("updated_at").notNull()
})
<!-- gh-comment-id:2746058165 --> @akucharczyk commented on GitHub (Mar 23, 2025): As a workaround I just created my own file for drizzle, which seams to work fine. ```js // stripe.ts import { integer, boolean, text, timestamp, pgTable } from 'drizzle-orm/pg-core' // Create the subscription table export const subscription = pgTable('subscription', { id: text('id').primaryKey(), plan: text('plan').notNull(), referenceId: text('reference_id').notNull(), // User ID or org ID stripeCustomerId: text('stripe_customer_id'), stripeSubscriptionId: text('stripe_subscription_id'), status: text('status').notNull(), // active, canceled, etc. periodStart: timestamp('period_start'), periodEnd: timestamp('period_end'), cancelAtPeriodEnd: boolean('cancel_at_period_end'), seats: integer('seats'), trialStart: timestamp('trial_start'), trialEnd: timestamp('trial_end'), }) ``` also added to my `auth-schema.ts` ```js export const user = pgTable("user", { id: text("id").primaryKey(), name: text("name").notNull(), email: text("email").notNull().unique(), emailVerified: boolean("email_verified").notNull(), image: text("image"), // stripe customer id stripeCustomerId: text('stripe_customer_id'), createdAt: timestamp("created_at").notNull(), updatedAt: timestamp("updated_at").notNull() }) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8842