Detect when postgres is used instead of postgresql.
This commit is contained in:
@@ -2,14 +2,25 @@ require('dotenv').config();
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const databaseType =
|
||||
process.env.DATABASE_TYPE || (process.env.DATABASE_URL && process.env.DATABASE_URL.split(':')[0]);
|
||||
function getDatabase() {
|
||||
const type =
|
||||
process.env.DATABASE_TYPE ||
|
||||
(process.env.DATABASE_URL && process.env.DATABASE_URL.split(':')[0]);
|
||||
|
||||
if (type === 'postgres') {
|
||||
return 'postgresql';
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
const databaseType = getDatabase();
|
||||
|
||||
if (!databaseType || !['mysql', 'postgresql'].includes(databaseType)) {
|
||||
throw new Error('Missing or invalid database');
|
||||
}
|
||||
|
||||
console.log(`Database schema detected: ${databaseType}`);
|
||||
console.log(`Database type detected: ${databaseType}`);
|
||||
|
||||
const src = path.resolve(__dirname, `../prisma/schema.${databaseType}.prisma`);
|
||||
const dest = path.resolve(__dirname, '../prisma/schema.prisma');
|
||||
|
||||
Reference in New Issue
Block a user