mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
32 lines
770 B
JavaScript
32 lines
770 B
JavaScript
/* eslint-disable no-console */
|
|
import 'dotenv/config';
|
|
import fse from 'fs-extra';
|
|
import path from 'node:path';
|
|
import del from 'del';
|
|
|
|
function getDatabaseType(url = process.env.DATABASE_URL) {
|
|
const type = process.env.DATABASE_TYPE || (url && 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(process.cwd(), `db/${databaseType}`);
|
|
const dest = path.resolve(process.cwd(), 'prisma');
|
|
|
|
del.sync(dest);
|
|
|
|
fse.copySync(src, dest);
|
|
|
|
console.log(`Copied ${src} to ${dest}`);
|