mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Refactor migrations.
This commit is contained in:
parent
5899a8d45c
commit
3122bab419
15 changed files with 46 additions and 65 deletions
30
scripts/copy-db-files.js
Normal file
30
scripts/copy-db-files.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
require('dotenv').config();
|
||||
const fse = require('fs-extra');
|
||||
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, `../db/${databaseType}`);
|
||||
const dest = path.resolve(__dirname, '../prisma');
|
||||
|
||||
fse.copySync(src, dest);
|
||||
|
||||
console.log(`Copied ${src} to ${dest}`);
|
||||
Loading…
Add table
Add a link
Reference in a new issue