Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating Prisma client without any model in its schema #11582

Closed
pzaenger opened this issue Feb 2, 2022 · 17 comments · Fixed by #24160
Closed

Generating Prisma client without any model in its schema #11582

pzaenger opened this issue Feb 2, 2022 · 17 comments · Fixed by #24160
Assignees
Labels
good first issue Always wanted to get involved in an open source project but don’t know where to begin? Welcome! kind/feature A request for a new feature. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: dx topic: prisma generate CLI: prisma generate topic: raw $queryRaw(Unsafe) and $executeRaw(Unsafe): https://www.prisma.io/docs/concepts/components/prisma-cli
Milestone

Comments

@pzaenger
Copy link

pzaenger commented Feb 2, 2022

Problem

We have a server template including Prisma, which works fine so far. However, we now have another server extending this template without the need of models - just raw queries. While generating the Prisma client, via npx prisma generate, it is complaining about not having at least one model.

$ npx prisma generate
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Error: 
You don't have any models defined in your schema.prisma, so nothing will be generated.

Obviously correct - but in this case not wanted. So, we would like to use Prisma with basically $queryRaw and $queryRawUnsafe only.

Suggested solution

It should be allowed to generate the Prisma Client without existing models in its schema.

Alternatives

First guess would be to add a dummy model.

@pantharshit00 pantharshit00 added kind/feature A request for a new feature. team/client Issue for team Client. topic: prisma generate CLI: prisma generate labels Feb 4, 2022
@janpio janpio added topic: dx topic: raw $queryRaw(Unsafe) and $executeRaw(Unsafe): https://www.prisma.io/docs/concepts/components/prisma-cli labels Feb 9, 2022
@janpio
Copy link
Member

janpio commented Feb 9, 2022

Interesting and valid use case. If we remove this hard limitation, we should probably find a way to instead communicate the missing of models another way to point it out to first time users of Prisma.

@jalal-uddin-sazim

This comment was marked as abuse.

@Gaen
Copy link

Gaen commented Mar 16, 2023

Upvoting. Start with a flag maybe? Like npx prisma generate --allow-no-models

@adjamerson
Copy link

I'd also like support this suggestion. I'm in a very similar situation as the OP, working with a service template but some services don't need any models, just the client.

@IsraelDeAraujo
Copy link

Yeah! I want this feature too!

@QBoulanger
Copy link

Same for me.

@anaelChardan
Copy link

anaelChardan commented Jul 27, 2023

Same for me, I don't understand how to it possible to not have any types for at least $connect, and doing raw queries. It is necessary for a standalone library :/

@janpio janpio added the tech/typescript Issue for tech TypeScript. label Jul 28, 2023
@trustieee
Copy link

Same. I find myself creating a dummy model just to be able to use raw queries that aren't tied to a model.

@simonramosb
Copy link

Yes! I'm really needing this feature too!

@janpio janpio added the good first issue Always wanted to get involved in an open source project but don’t know where to begin? Welcome! label Aug 31, 2023
@rockingrohit9639
Copy link

@janpio I want to work on this issue, if you can guide me a little.

@janpio
Copy link
Member

janpio commented Oct 5, 2023

I would start searching our codebase for the error message string, and then try to understand how it is thrown - and how it could be avoided. (Note: The codebase is not only this repository, but also prisma-engines - so maybe is relates to that)

@rockingrohit9639
Copy link

I would start searching our codebase for the error message string, and then try to understand how it is thrown - and how it could be avoided. (Note: The codebase is not only this repository, but also prisma-engines - so maybe is relates to that)

Thank you.

@kivanval
Copy link

Hi, thought I'd make my first contribution to open source :D
@janpio I see that people come to you with questions, so after PR I just have to wait for some kind of result?

@joeyaurel
Copy link

joeyaurel commented Jan 26, 2024

@janpio I like @kivanval's PR #22046. What do you think?

@kivanval
Copy link

@joeyaurel, I've already forgotten for updating the branch, took too long to accept, then need to revisit the decision again as CI breaks. :)

@Progyan-APAC
Copy link

@janpio Any further update on this?

@gutyerrez
Copy link
Contributor

@janpio Any further update on this?

The pr #24160 will close this issue

@Jolg42 Jolg42 added this to the 5.14.0 milestone May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Always wanted to get involved in an open source project but don’t know where to begin? Welcome! kind/feature A request for a new feature. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: dx topic: prisma generate CLI: prisma generate topic: raw $queryRaw(Unsafe) and $executeRaw(Unsafe): https://www.prisma.io/docs/concepts/components/prisma-cli
Projects
None yet