Additional Fields default value not being applied (drizzle)

In my auth.ts I am trying to add a few fields to the user table
user: {
additionalFields: {
firstName: {
type: "string",
required: true,
fieldName: "first_name",
},
lastName: {
type: "string",
required: true,
fieldName: "last_name",
},
dob: {
type: "date",
required: true,
fieldName: "dob",
},
rollingNetDepositLimit: {
type: "number",
required: true,
fieldName: "rolling_net_deposit_limit",
defaultValue: 160000,
},
isLocked: {
type: "boolean",
required: true,
fieldName: "is_locked",
defaultValue: false,
},
},
},
user: {
additionalFields: {
firstName: {
type: "string",
required: true,
fieldName: "first_name",
},
lastName: {
type: "string",
required: true,
fieldName: "last_name",
},
dob: {
type: "date",
required: true,
fieldName: "dob",
},
rollingNetDepositLimit: {
type: "number",
required: true,
fieldName: "rolling_net_deposit_limit",
defaultValue: 160000,
},
isLocked: {
type: "boolean",
required: true,
fieldName: "is_locked",
defaultValue: false,
},
},
},
I have this command in my package.json to
"auth:generate": "pnpm dlx @better-auth/cli@latest generate --y --output ./lib/server/schema/auth.schema.ts && prettier --write ./lib/server/schema/auth.schema.ts",
"auth:generate": "pnpm dlx @better-auth/cli@latest generate --y --output ./lib/server/schema/auth.schema.ts && prettier --write ./lib/server/schema/auth.schema.ts",
that will generate to auth.schema.ts but when the user table is being generated it displays this
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"),
createdAt: timestamp("created_at").notNull(),
updatedAt: timestamp("updated_at").notNull(),
phoneNumber: text("phone_number").unique(),
phoneNumberVerified: boolean("phone_number_verified"),
firstName: text("first_name").notNull(),
lastName: text("last_name").notNull(),
dob: timestamp("dob").notNull(),
rollingNetDepositLimit: integer("rolling_net_deposit_limit").notNull(),
isLocked: boolean("is_locked").notNull(),
});
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"),
createdAt: timestamp("created_at").notNull(),
updatedAt: timestamp("updated_at").notNull(),
phoneNumber: text("phone_number").unique(),
phoneNumberVerified: boolean("phone_number_verified"),
firstName: text("first_name").notNull(),
lastName: text("last_name").notNull(),
dob: timestamp("dob").notNull(),
rollingNetDepositLimit: integer("rolling_net_deposit_limit").notNull(),
isLocked: boolean("is_locked").notNull(),
});
it makes the fields required but the default values are not being applied
6 Replies
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Rufis
RufisOP3mo ago
when I tried to sign up it gives this error, stating that the field is required. I am using Supabase and it doesn't apply the default to field
No description
No description
Rufis
RufisOP3mo ago
A default on Supabase would look like this, where the default value has already been applied.
No description
Rufis
RufisOP3mo ago
I tried to change it so it will be input: false but this didnt fix it
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Rufis
RufisOP3mo ago
GitHub
Additional Fields not setting default value (drizzle) · Issue #1343...
Is this suited for github? Yes, this is suited for github To Reproduce EX: I ran: "auth:generate": "pnpm dlx @better-auth/cli@latest generate --y --output ./lib/server/schema/auth.sc...

Did you find this page helpful?