How to set up a development and production database with Prisma

I'm trying to set up two databases with prisma but there isn't much info available. I am trying to use a local postgres db for my dev db and supabase for my prod db.
datasource db {
provider = "postgresql"
// NOTE: When using postgresql, mysql or sqlserver, uncomment the @db.Text annotations in model Account below
// Further reading:
// https://next-auth.js.org/adapters/prisma#create-the-prisma-schema
// https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string
url = env("DATABASE_URL")
}

datasource development {
provider = "postgresql"
url = env("DEV_DATABASE_URL")
}
datasource db {
provider = "postgresql"
// NOTE: When using postgresql, mysql or sqlserver, uncomment the @db.Text annotations in model Account below
// Further reading:
// https://next-auth.js.org/adapters/prisma#create-the-prisma-schema
// https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string
url = env("DATABASE_URL")
}

datasource development {
provider = "postgresql"
url = env("DEV_DATABASE_URL")
}
This is giving me an error in the schema file so im not sure how to go about doing this.
3 Replies
Brendonovich
Brendonovich2y ago
You only need one datasource, just change your DATABASE_URL environment variable to switch databases
MoltenFuzzy
MoltenFuzzyOP2y ago
okay 👍 didnt think about that ty
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server