[GH-ISSUE #1387] Schema generation via cli does not respect defaultValue while using Drizzle adapter #8724

Closed
opened 2026-04-13 03:53:21 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @ardasoyturk on GitHub (Feb 8, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1387

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Create a plugin extending the user schema
  2. Add a field which includes a defaultValue

Example:

is_verified: {
            type: "boolean",
            required: true,
            unique: false,
            defaultValue: false,
          }

Current vs. Expected behavior

Following the steps from the previous action, the generated schema file should include a default value in the field. The output should look like this:

Image
But instead of that, we don't get the .default(false) part and the output is like this:
Image

Due to this error, we encounter the following message: Failed to create user [error: null value in column "is_verified" of relation "user" violates not-null constraint']

I noticed this issue previously in #1343 but I was unable to reopen it due to insufficient permissions. That is why I am creating this new issue.

What version of Better Auth are you using?

1.1.16

Provide environment information

- OS: Windows 11
- Browser: Chrome, Firefox (the issue is not about the browser)

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

Package

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { username } from "better-auth/plugins";
import { emailHarmony } from "better-auth-harmony";

import { db } from "@/lib/db";
import { account, session, user, verification } from "@/lib/db/schema";
import { userExtenderPlugin } from "./plugins/extend-user";

export const auth = betterAuth({
  database: drizzleAdapter(db, {
    provider: "pg",
    schema: {
      user,
      session,
      verification,
      account,
    },
  }),
  emailAndPassword: {
    enabled: true, // If you want to use email and password auth
  },
  socialProviders: {
    google: {
      clientId: process.env.GOOGLE_CLIENT_ID!,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
    },
  },
  plugins: [username(), emailHarmony(), userExtenderPlugin()],
});

Additional context

No response

Originally created by @ardasoyturk on GitHub (Feb 8, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1387 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Create a plugin extending the user schema 2. Add a field which includes a defaultValue Example: ```js is_verified: { type: "boolean", required: true, unique: false, defaultValue: false, } ``` ### Current vs. Expected behavior Following the steps from the previous action, the generated schema file should include a default value in the field. The output should look like this: ![Image](https://github.com/user-attachments/assets/324e5704-1910-4cca-8ed8-9a58644ab04e) But instead of that, we don't get the `.default(false)` part and the output is like this: ![Image](https://github.com/user-attachments/assets/4f36d49a-f4f1-4ab1-8094-4c315da5998f) Due to this error, we encounter the following message: `Failed to create user [error: null value in column "is_verified" of relation "user" violates not-null constraint']` I noticed this issue previously in #1343 but I was unable to reopen it due to insufficient permissions. That is why I am creating this new issue. ### What version of Better Auth are you using? 1.1.16 ### Provide environment information ```bash - OS: Windows 11 - Browser: Chrome, Firefox (the issue is not about the browser) ``` ### Which area(s) are affected? (Select all that apply) Package ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { drizzleAdapter } from "better-auth/adapters/drizzle"; import { username } from "better-auth/plugins"; import { emailHarmony } from "better-auth-harmony"; import { db } from "@/lib/db"; import { account, session, user, verification } from "@/lib/db/schema"; import { userExtenderPlugin } from "./plugins/extend-user"; export const auth = betterAuth({ database: drizzleAdapter(db, { provider: "pg", schema: { user, session, verification, account, }, }), emailAndPassword: { enabled: true, // If you want to use email and password auth }, socialProviders: { google: { clientId: process.env.GOOGLE_CLIENT_ID!, clientSecret: process.env.GOOGLE_CLIENT_SECRET!, }, }, plugins: [username(), emailHarmony(), userExtenderPlugin()], }); ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-13 03:53:21 -05:00
Author
Owner

@shahreaz0 commented on GitHub (Apr 9, 2025):

same for prisma also

<!-- gh-comment-id:2790554383 --> @shahreaz0 commented on GitHub (Apr 9, 2025): same for prisma also
Author
Owner

@ardasoyturk commented on GitHub (May 20, 2025):

closing since the issue has been fixed with #2506

<!-- gh-comment-id:2895368682 --> @ardasoyturk commented on GitHub (May 20, 2025): closing since the issue has been fixed with #2506
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8724