[GH-ISSUE #323] Unable to generate Prisma schema for the database. #8219

Closed
opened 2026-04-13 03:19:07 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @0xPratikPatil on GitHub (Oct 24, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/323

Describe the bug
Unable to generate Prisma schema for the database.

To Reproduce

import { PrismaClient } from "@prisma/client";
import { prismaAdapter } from "better-auth/adapters/prisma";

const prisma = new PrismaClient();

export const auth = betterAuth({
  database: prismaAdapter(prisma, {
    provider: "postgresql",
  }),

Empty Schema nothing else

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

Commands Used
bunx @better-auth/cli generate
Even after running the command bunx prisma generate, it didn't work.

Expected behavior
It generates the Prisma schema according to the auth setup and creates appropriate tables/schemas.

Screenshots

Screenshot 2024-10-24 at 7 07 47 PM

Additional context
Version : ^0.5.4-beta.6

Originally created by @0xPratikPatil on GitHub (Oct 24, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/323 **Describe the bug** Unable to generate Prisma schema for the database. **To Reproduce** ``` import { PrismaClient } from "@prisma/client"; import { prismaAdapter } from "better-auth/adapters/prisma"; const prisma = new PrismaClient(); export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "postgresql", }), ``` Empty Schema nothing else ``` generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } ``` **Commands Used** `bunx @better-auth/cli generate ` Even after running the command `bunx prisma generate`, it didn't work. **Expected behavior** It generates the Prisma schema according to the auth setup and creates appropriate tables/schemas. **Screenshots** <img width="1131" alt="Screenshot 2024-10-24 at 7 07 47 PM" src="https://github.com/user-attachments/assets/dfba35f2-f2f6-4ae4-89cf-753a4e90beb0"> **Additional context** Version : ^0.5.4-beta.6
GiteaMirror added the locked label 2026-04-13 03:19:07 -05:00
Author
Owner

@Bekacru commented on GitHub (Oct 24, 2024):

initiate the prisma client before you try to generate the schema

<!-- gh-comment-id:2435386369 --> @Bekacru commented on GitHub (Oct 24, 2024): initiate the prisma client before you try to generate the schema
Author
Owner

@0xPratikPatil commented on GitHub (Oct 24, 2024):

Yes, it worked. The catch is that I was running with an empty schema. First, I had to create a random schema to initialize it, then generate the real one.Thank You.

<!-- gh-comment-id:2435417826 --> @0xPratikPatil commented on GitHub (Oct 24, 2024): Yes, it worked. The catch is that I was running with an empty schema. First, I had to create a random schema to initialize it, then generate the real one.Thank You.
Author
Owner

@0xPratikPatil commented on GitHub (Oct 24, 2024):

I don't know why, but when I shifted to Prisma + MongoDB, my signUp.username() stopped working. However, I can still use signUp.email() to register via username as the field is optional.

<!-- gh-comment-id:2435502924 --> @0xPratikPatil commented on GitHub (Oct 24, 2024): I don't know why, but when I shifted to Prisma + MongoDB, my signUp.username() stopped working. However, I can still use signUp.email() to register via username as the field is optional.
Author
Owner

@Bekacru commented on GitHub (Oct 24, 2024):

yeah it's moved to signUp.email since a couple of versions back

<!-- gh-comment-id:2435678708 --> @Bekacru commented on GitHub (Oct 24, 2024): yeah it's moved to signUp.email since a couple of versions back
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8219