mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-16 02:05:04 +01:00
34 lines
770 B
JavaScript
34 lines
770 B
JavaScript
require('dotenv').config();
|
|
const fse = require('fs-extra');
|
|
const path = require('path');
|
|
const del = require('del');
|
|
|
|
function getDatabaseType() {
|
|
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 = getDatabaseType();
|
|
|
|
if (!databaseType || !['mysql', 'postgresql'].includes(databaseType)) {
|
|
throw new Error('Missing or invalid database');
|
|
}
|
|
|
|
console.log(`Database type detected: ${databaseType}`);
|
|
|
|
const src = path.resolve(__dirname, `../db/${databaseType}`);
|
|
const dest = path.resolve(__dirname, '../prisma');
|
|
|
|
del.sync(dest);
|
|
|
|
fse.copySync(src, dest);
|
|
|
|
console.log(`Copied ${src} to ${dest}`);
|