mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 23:27:12 +01:00
Switched to type: module.
This commit is contained in:
parent
615a6d444f
commit
4e37e10b6d
20 changed files with 25 additions and 50 deletions
32
scripts/copy-db-files.js
Normal file
32
scripts/copy-db-files.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* 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}`);
|
||||
Loading…
Add table
Add a link
Reference in a new issue