P
Prisma2mo ago
JeanPSF

schema env file

Is there a way to dinamically chose the env file that schema.prisma will use? For example:
datasource db {
provider = "mysql"
url = env("ADMIN_DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
}
datasource db {
provider = "mysql"
url = env("ADMIN_DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
}
datasource db {
provider = "mysql"
url = env.stage("ADMIN_DATABASE_URL")
shadowDatabaseUrl = env.stage("SHADOW_DATABASE_URL")
}
datasource db {
provider = "mysql"
url = env.stage("ADMIN_DATABASE_URL")
shadowDatabaseUrl = env.stage("SHADOW_DATABASE_URL")
}
datasource db {
provider = "mysql"
url = env.dev("ADMIN_DATABASE_URL")
shadowDatabaseUrl = env.dev("SHADOW_DATABASE_URL")
}
datasource db {
provider = "mysql"
url = env.dev("ADMIN_DATABASE_URL")
shadowDatabaseUrl = env.dev("SHADOW_DATABASE_URL")
}
.env
.stage.env
.dev.env
.env
.stage.env
.dev.env
1 Reply
kmj
kmj2mo ago
if you are using nodejs, you can add below code to app.js if(process.env.NODE_ENV){ require('dotenv').config({path: '.' + process.env.NODE_ENV + '.env' + }) }else{ require('dotenv').config() } then using below script to defined which NODE_ENV you want to use cross-env NODE_ENV=stage nodemon src/app.js