DefaultValue field does not work #1298

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

Originally created by @TreeOfSelf on GitHub (Jun 3, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

    additionalFields: {
      credits: {
        type: "number",
        required: false,
        defaultValue: 5,
        input: false,
      },
    },

Current vs. Expected behavior

Running npx @better-auth/cli generate

This should produce the resulting SQL

"credits" INTEGER DEFAULT 0

Instead it produces

"credits" INTEGER

as the defaultValue is essentially ignored entirely.

What version of Better Auth are you using?

1.2.8

Provide environment information

- Debian 12

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

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
import dotenv from 'dotenv';
import { pool } from "../database/db.js";
dotenv.config({ path: '.env.local' });

export const auth = betterAuth({
  trustedOrigins: [process.env.CLIENT_ORIGIN],
  emailAndPassword: {
    enabled: true
  },
  user: {
    additionalFields: {
      credits: {
        type: "number",
        required: false,
        defaultValue: 0,
        input: false,
      },
    },
  },
  database: pool,
});

Additional context

No response

Originally created by @TreeOfSelf on GitHub (Jun 3, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce ```js additionalFields: { credits: { type: "number", required: false, defaultValue: 5, input: false, }, }, ``` ### Current vs. Expected behavior Running ` npx @better-auth/cli generate ` This should produce the resulting SQL ```sql "credits" INTEGER DEFAULT 0 ``` Instead it produces ```sql "credits" INTEGER ``` as the defaultValue is essentially ignored entirely. ### What version of Better Auth are you using? 1.2.8 ### Provide environment information ```bash - Debian 12 ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" import dotenv from 'dotenv'; import { pool } from "../database/db.js"; dotenv.config({ path: '.env.local' }); export const auth = betterAuth({ trustedOrigins: [process.env.CLIENT_ORIGIN], emailAndPassword: { enabled: true }, user: { additionalFields: { credits: { type: "number", required: false, defaultValue: 0, input: false, }, }, }, database: pool, }); ``` ### Additional context _No response_
Author
Owner

@Kinfe123 commented on GitHub (Jun 3, 2025):

can you try this one -

npm i https://pkg.pr.new/better-auth/better-auth@2885
@Kinfe123 commented on GitHub (Jun 3, 2025): can you try this one - ``` npm i https://pkg.pr.new/better-auth/better-auth@2885 ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1298