DEV Community

Cover image for Playing Around with Prisma
aminah
aminah

Posted on

Playing Around with Prisma

tl;dr
I'm using Create T3 App to build my personal professional website, which includes a blog, to get familiar with all of the tech stack. I was able to easily find out that I couldn't use multiple databases for different environments, and the Prisma documentation was really helpful in find out that information.

So I'm building a Create T3 App to renovate my personal professional website, and I'm trying to set up a local database to build out my schema and test out the APIs for my personal professional website/blog and I come across an issue.

I wanted to use sqlite3 locally and PostgreSQL in production, but the Prisma schema no longer allows for multiple datasources.

First I tried adding an environment variable for the provider like so:

datasource db {
  provider = env("DATABASE_PROVIDER")
  url      = env("DATABASE_URL")
}
Enter fullscreen mode Exit fullscreen mode

but was met with the following error: A datasource must not use the env() function in the provider argument.

That knocked one potential path out of the game. So then I tried adding multiple providers using an array.

Previously, if you wanted to use a different database locally than in production, you could do something like:

datasource db {
  provider = ["postgresql", sqlite"]
  url      = env("DATABASE_URL")
}
Enter fullscreen mode Exit fullscreen mode

but when I entered that, I was met with this error: Error validating datasource 'postgresql': You defined more than one datasource. This is not allowed yet because support for multiple databases has not been implemented yet.

Luckily the team over at Prisma made sure we knew what the deal was, so they gave us a heads up in the docs:

Prisma documentation detailing only one datasource allowed

as well as linked us to the GitHub deprecation issue, which outlined the implications of this deprecation:

GitHub issue detailing implications of removal of multiplr datasources

I ended up setting up PostgreSQL locally as well, which they provided instructions on how to do.

All in all, I'm having a great time building this project because of the great documentation by the Prisma team.

Top comments (0)