We would like to use sqlite for local development,...
# orm-help
m
We would like to use sqlite for local development, but postgresql for production -> how should we go about it? I see that database
url
in datasource block can be defined via an ENV var, which is great, but
provider
can't, which means it is fixed.
n
Hey Martin 👋 thanks for raising this! It's indeed not possible to set the
provider
dynamically. We actually used to consider this workflow (SQLite in development, Postgres in production) in the past but after talking to a number of users, we decided that this is probably not a good practice for Prisma users. The strongest argument that speaks against this ist that the Prisma schema capabilities (as well as the generated Prisma Client code) change depending on the
provider
. For example,
enum
definitions are possible with Postgres, but not with SQLite. The goal of Prisma is to be able to expose the specific features of the underlying DB, and since SQLite doesn't natively support enums, Prisma does not allow their usage in the Prisma schema either. Does that resonate with you? Let me know if you have any further questions, always happy to help 🙂
In addition to the varying schema capabilities and Prisma Client code, another argument for using the same
provider
throughout all stages is to reduce potential surprises in behavior when deploying to production.
m
@nikolasburk that makes complete sense! Do you think it would be useful to have this mentioned in documentation, kind of as "best practices"? While it seems relatively obvious now, it wasn't as obvious to me before!
👌 1
n
Yes, totally! I created an issue in our docs repo to track this 🙌