Switched to type: module.

This commit is contained in:
Mike Cao 2025-04-29 14:36:52 -07:00
parent 615a6d444f
commit 4e37e10b6d
20 changed files with 25 additions and 50 deletions

32
scripts/copy-db-files.js Normal file
View 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}`);