Why im getting error : The field "identifier" does not exist in the "verification" schema. ?

I have created separate schema files, and im passing all schema in betterAuth() When i click on login button its showing error in terminal also i have migrated all the schema. i have made one change in all the schema since user schema i already created. there for id key im using uuid since i made change every schema text() to uuid() Can anyone help me to resolve this?
No description
No description
No description
19 Replies
varundeva
varundevaOP•4w ago
Here its drizzle kit stuido shows all the columns
No description
bekacru
bekacru•4w ago
can you share your whole auth config?
varundeva
varundevaOP•4w ago
These are the main files related to drizzle and better-auth
No description
No description
No description
No description
No description
No description
No description
bekacru
bekacru•4w ago
this seems like it should work. maybe try removing the schema object passed to the adapter or pass the 4 tables explicitly, dont destructure it.
varundeva
varundevaOP•4w ago
Ok let me try this I just destructured because all the 4 table and schema names same as mentioned in documentation,
bekacru
bekacru•4w ago
yeah I understand just incase.
varundeva
varundevaOP•4w ago
Yes I'll try that Because I checked discord and reddit No one mentioned this error earlier Maybe something wrong in my code because i have additional columns and tables
varundeva
varundevaOP•4w ago
@bekacru i have tried, still same error 😦
No description
varundeva
varundevaOP•4w ago
I made changes back to text() from uuid() for id key still same issue 🙂
bekacru
bekacru•4w ago
can you make something reproducible? or if this is open source happy to take a look.
varundeva
varundevaOP•3w ago
I'll share github link with you I have shared repo url to you in direct message Any hint? Why it's making issue
bekacru
bekacru•3w ago
here in your user table
export const user = pgTable("user", {
id: text("id").primaryKey(),
email: varchar("email", { length: 64 }).unique().notNull(),
userId: varchar("user_id", { length: 32 }).unique(),
firstName: varchar("first_name", { length: 32 }).notNull(),
lastName: varchar("last_name", { length: 32 }),
emailVerified: boolean("email_verified").notNull(),
image: text("image"),
birthDay: date("birthday"),
mobile: varchar("mobile", { length: 16 }).unique().notNull(),
password: varchar("password", { length: 256 }),
bloodGroup: bloodGroups("blood_group"),
isActive: boolean("is_active").default(true),
isVerified: boolean("is_verified").default(false),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
})
export const user = pgTable("user", {
id: text("id").primaryKey(),
email: varchar("email", { length: 64 }).unique().notNull(),
userId: varchar("user_id", { length: 32 }).unique(),
firstName: varchar("first_name", { length: 32 }).notNull(),
lastName: varchar("last_name", { length: 32 }),
emailVerified: boolean("email_verified").notNull(),
image: text("image"),
birthDay: date("birthday"),
mobile: varchar("mobile", { length: 16 }).unique().notNull(),
password: varchar("password", { length: 256 }),
bloodGroup: bloodGroups("blood_group"),
isActive: boolean("is_active").default(true),
isVerified: boolean("is_verified").default(false),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
})
firstName for example is non nullable. better auth doesn't set first name when creating user and name field doesn't exist which it'll try to set. there is no password field on the usre table as well. So first fix those.
varundeva
varundevaOP•3w ago
Can i split name to first and last? And map that? Any provisions available like that?
bekacru
bekacru•3w ago
Maybe one thing you can do if the error still persists initiate a new project and use the cli to generate the schema and make the auth part work without anything additional then move things back after that. you can map it but you still need the name field if you add them, you also need to speceifcy you have added those fields in your auth config and you can map the profile in the provider config
varundeva
varundevaOP•3w ago
Oh ok Let me try this first 🙂 Thank you Because error was showing in verification table. So not much bothered about other tables
varundeva
varundevaOP•3w ago
@bekacru i have just created new project and tried default as it is, its working. after that every places i changed schema id key type from text to uuid and in auth.ts advanced object id generation made false, now throwing new error from the verification schema
No description
varundeva
varundevaOP•3w ago
its working, deleted database and created again with latest migration @bekacru found one issue. if all the schema is in root folder which is default generated auth-schema.ts then everything working fine. if i split schema into multiple files then error is getting in each schema i made it as default export. now everything working fine
varundeva
varundevaOP•3w ago
I implemented google signin button one more thing noticed. Just clicked google login button and onthing happend in ui. i can see POST /api/auth/sign-in/social 200 in 1297ms in terminal and 1 row created in verification table. when i click again google login button it redirects to choose account
No description
varundeva
varundevaOP•3w ago
This issue also resolved 🙂

Did you find this page helpful?