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
16
scripts/check-db.js
Normal file
16
scripts/check-db.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
require('dotenv').config();
|
||||
const { PrismaClient } = require('@prisma/client');
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function check() {
|
||||
await prisma.account.findMany({ limit: 1 });
|
||||
}
|
||||
|
||||
check()
|
||||
.catch(e => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
|
|
@ -22,16 +22,9 @@ if (!databaseType || !['mysql', 'postgresql'].includes(databaseType)) {
|
|||
|
||||
console.log(`Database type detected: ${databaseType}`);
|
||||
|
||||
const src = path.resolve(__dirname, `../prisma/schema.${databaseType}.prisma`);
|
||||
const dest = path.resolve(__dirname, '../prisma/schema.prisma');
|
||||
const src = path.resolve(__dirname, `../db/${databaseType}`);
|
||||
const dest = path.resolve(__dirname, '../prisma');
|
||||
|
||||
fse.copyFileSync(src, dest);
|
||||
fse.copySync(src, dest);
|
||||
|
||||
console.log(`Copied ${src} to ${dest}`);
|
||||
|
||||
const srcMigrations = path.resolve(__dirname, `../prisma/${databaseType}/migrations`);
|
||||
const destMigrations = path.resolve(__dirname, `../prisma/migrations`);
|
||||
|
||||
fse.copySync(srcMigrations, destMigrations);
|
||||
|
||||
console.log(`Copied ${srcMigrations} to ${destMigrations}`);
|
||||
Loading…
Add table
Add a link
Reference in a new issue