P
Prisma•2d ago
sid

Studio is not working with multifile schemas

I have created a folder schema and added the following code to the schema.prisma file
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}

generator client {
provider = "prisma-client-js"
previewFeatures = ["prismaSchemaFolder"]
}
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}

generator client {
provider = "prisma-client-js"
previewFeatures = ["prismaSchemaFolder"]
}
I can read from and write to the database, but when I run Prisma Studio, I get the following error: The table main.User does not exist in the current database.
8 Replies
Nurul
Nurul•2d ago
Hello @sid 👋 What is your prisma version? I just tried using Prisma studio with prismaSchemaFolder in a sqlite database and it worked as expected for me. This was my schema file
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
previewFeatures = ["prismaSchemaFolder"]
}

datasource db {
provider = "sqlite"
url = "file:./dev.db"
}
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
previewFeatures = ["prismaSchemaFolder"]
}

datasource db {
provider = "sqlite"
url = "file:./dev.db"
}
And this was my user.prisma file
model User {
id Int @id @default(autoincrement())
name String
email String
}
model User {
id Int @id @default(autoincrement())
name String
email String
}
Nurul
Nurul•2d ago
When I ran npx prisma studio The user model opened as expected
No description
sid
sidOP•2d ago
Hi! I have 6.0.1 prisma and client.
Nurul
Nurul•2d ago
I tried it on 6.0.1 and it still works Did you run npx prisma db push or npx prisma migrate dev?
sid
sidOP•2d ago
I tried setting:
DATABASE_URL="file:./dev.db"
DATABASE_URL="file:./dev.db"
and it works fine. Thanks! However, when I use DATABASE_URL="file:../dev.db" I get the following error. Is this a bug or intended behavior?
Nurul
Nurul•2d ago
No, it should work as expected. The change you did just changes the location of db file. I tried changing the location of db in schema file like this:
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
previewFeatures = ["prismaSchemaFolder"]
}

datasource db {
provider = "sqlite"
url = "file:../dev.db"
}
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
previewFeatures = ["prismaSchemaFolder"]
}

datasource db {
provider = "sqlite"
url = "file:../dev.db"
}
And it worked as expected (see the new dev.db created outside prisma folder)
No description
sid
sidOP•2d ago
I am still getting this error with the parent directory. Is there anything I can provide to help figure out the cause? Or do I need to clear some Prisma cache or something like that?
Nurul
Nurul•2d ago
Could you try running npx prisma db push before running npx prisma studio and check if you still get the same error?
Want results from more Discord servers?
Add your server