Need help in adding Custom Table Names

I donno where I went wrong
21 Replies
Logesh
LogeshOP7d ago
✓ Compiled /api/auth/[...all] in 709ms (440 modules) prisma:query SELECT "public"."User"."id", "public"."User"."name", "public"."User"."email", "public"."User"."createdAt", "public"."User"."updatedAt", "public"."User"."emailVerified", "public"."User"."image" FROM "public"."User" WHERE "public"."User"."email" = $1 LIMIT $2 OFFSET $3 prisma:query INSERT INTO "public"."User" ("id","name","email","createdAt","updatedAt","emailVerified") VALUES ($1,$2,$3,$4,$5,$6) RETURNING "public"."User"."id", "public"."User"."name", "public"."User"."email", "public"."User"."createdAt", "public"."User"."updatedAt", "public"."User"."emailVerified", "public"."User"."image" prisma:error Invalid prisma.account.create() invocation: { data: { accountId: "3BAfEkg1jx9QJtiVGSlYhjzJAm5chngO", providerId: "credential", userId: "3BAfEkg1jx9QJtiVGSlYhjzJAm5chngO", password: "ebd6311b018ef66baac1750c0a4dce1a:a5feb3c830e8b5c2911fad5395c050255b9ed10797f72bd85b47a54ab4f703e35d951dbc580e1930eae709f2d49bd54979a1caaabe6595c68f72986385fd4859", createdAt: new Date("2025-04-23T22:18:05.596Z"), updatedAt: new Date("2025-04-23T22:18:05.596Z"), id: "TlCQJEOM7ZeacFhFwY9s52FE2gXxCPFi", + name: String }, select: undefined } Argument name is missing. SERVER_ERROR: PrismaClientValidationError: Invalid prisma.account.create() invocation: { data: { accountId: "3BAfEkg1jx9QJtiVGSlYhjzJAm5chngO", providerId: "credential", userId: "3BAfEkg1jx9QJtiVGSlYhjzJAm5chngO", password: "ebd6311b018ef66baac1750c0a4dce1a:a5feb3c830e8b5c2911fad5395c050255b9ed10797f72bd85b47a54ab4f703e35d951dbc580e1930eae709f2d49bd54979a1caaabe6595c68f72986385fd4859", createdAt: new Date("2025-04-23T22:18:05.596Z"), updatedAt: new Date("2025-04-23T22:18:05.596Z"), id: "TlCQJEOM7ZeacFhFwY9s52FE2gXxCPFi", + name: String }, select: undefined } Argument name is missing. this is the error I got as it is creating in the account model but not in the AuthAccount model.
Firro
Firro7d ago
Are you calling the account creation yourself or are you using the better-auth signup functionality?
Logesh
LogeshOP7d ago
using signup from better-auth.
Firro
Firro7d ago
Can you embed the relevant part as a message, I can't download stuff right now Also, importantly: Do you provide a name in the signup function call?
Logesh
LogeshOP7d ago
const { data, error: signUpError } = await signUp.email( { email, password, name, callbackURL: "/dashboard", }, { onError: (ctx) => { console.error("Error :", ctx.error); alert(ctx.error.message); }, } ); is this okay or do you need something else ?
Firro
Firro7d ago
Mhmm, are you 100% sure name is not empty here? That's what I'd check first Ok wait, I just realized, account shouldn't have a name Can you post the extended schema you did? Only the part for the account If you only wanted to change the name of the tables, it's surprising that an additional column snuck in
Logesh
LogeshOP7d ago
model Account { id String @id @default(cuid()) userId String name String type String balance Float currency String @default("USD") isDefault Boolean @default(false) creditLimit Float? dueDate DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt accountNumber String? institution String? notes String? isActive Boolean @default(true) user User @relation(fields: [userId], references: [id], onDelete: Cascade) transactions Transaction[] @relation("FromAccount") transfers Transaction[] @relation("ToAccount") recurringPayments RecurringPayment[] @@index([userId]) } this is the account but for this is not for better-auth , I need better-auth to use this model model AuthAccount { id String @id @default(cuid()) userId String accountId String providerId String password String? accessToken String? refreshToken String? idToken String? accessTokenExpiresAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@map("auth_accounts") }
Firro
Firro7d ago
Database | Better Auth
Learn how to use a database with Better Auth.
Logesh
LogeshOP7d ago
yes I tried from this
Firro
Firro7d ago
And then you've ran: npx @better-auth/cli generate? Because if so, hmm, tough, don't know why that shouldn't just work then
Logesh
LogeshOP7d ago
no I used npx prisma generate
Firro
Firro7d ago
Ahh. Maybe try running the better auth generate command and see what it outputs
Logesh
LogeshOP7d ago
let me try as you said
Firro
Firro7d ago
And then compare the two to see what you need to change In general I'd say you should have a section in your Prisma schema that you just always copy-paste over from the generated better auth schema instead of manually adding the columns And then the rest of your other application tables below it
Logesh
LogeshOP7d ago
didnt work , still stuck with the same error prisma:error Invalid prisma.account.create() invocation: { data: { accountId: "61owOGjhuhqTBQWY79bC51kr9ksQiANd", providerId: "credential", userId: "61owOGjhuhqTBQWY79bC51kr9ksQiANd", password: "84f7e8ce004b0dd3aafe6ee981346a02:1b12c8cbe040aaf3997212ceb4116280a2f84413c0c0d142c93713e4f0b2a823a4a6e473571d31731dc19c7592b03ab48daf7a6bd497d716915f9958715f3ef8", createdAt: new Date("2025-04-23T23:23:39.386Z"), updatedAt: new Date("2025-04-23T23:23:39.386Z"), id: "maorm6FwqdEkngBK7JDDmKfwg4c4ArUc", + name: String }, select: undefined } Argument name is missing.
Firro
Firro7d ago
Hmm, well, maybe someone else who is more familiar with Prisma+Better Auth could help then, wish you all the best
Logesh
LogeshOP7d ago
actually this prisma.account.create() is wrong model and it needs to be prisma.authAccount.create() that is the problem here
Firro
Firro7d ago
Yeah it feels like that, I'd triple check the auth.ts file But not that familiar with Prisma sorry
Logesh
LogeshOP7d ago
so you are saying we shouldnt disturb better-auth tables and work with other tables for applicaiton logic right ?
Firro
Firro7d ago
Nah, modifying them is 100% the way to go I did that as well, but for me it just worked But I'd not manually change them but via changing auth.ts -> better-auth/cli generate -> prisma generate -> prisma migrate So that your auth.ts is the source of truth Just have to figure out now why it accesses the wrong model
Logesh
LogeshOP7d ago
actually I have a table with name Account and I have built applicaiton based on that table, I thought of giving better-auth a try and I coudnt just rename my Account table . so I created another table as required by better-auth . and I couldnt able to point better-auth to use that table as account. Eventhough it was mentioned in docs

Did you find this page helpful?