commit
4047a7ec23
378 changed files with 29334 additions and 0 deletions
30
scripts/copy-db-schema.js
Normal file
30
scripts/copy-db-schema.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
require('dotenv').config();
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
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 type detected: ${databaseType}`);
|
||||
|
||||
const src = path.resolve(__dirname, `../prisma/schema.${databaseType}.prisma`);
|
||||
const dest = path.resolve(__dirname, '../prisma/schema.prisma');
|
||||
|
||||
fs.copyFileSync(src, dest);
|
||||
|
||||
console.log(`Copied ${src} to ${dest}`);
|
||||
Loading…
Add table
Add a link
Reference in a new issue