#Making prisma use different file than .env
5 messages · Page 1 of 1 (latest)
Hey 👋
You could try doing something like this:
If your config looks like this:
// config.ts
export const databaseConfig = {
development: 'postgresql://localhost/dev_db',
production: 'postgresql://localhost/prod_db',
};
You could initialise PrismaClient dynamically like this:
import { PrismaClient } from '@prisma/client';
import { databaseConfig } from './config';
const isProd = true ;// or false;
const connectionString = isProd ? databaseConfig.production : databaseConfig.development;
const prisma = new PrismaClient({
datasources: {
db: {
url: connectionString,
},
},
});
export default prisma;
hi, but that wouldn't work for migrations would it
Hmm, for prisma migrate it could be an issue 🤔
yeah