Updated to prisma 3.15.2. Updated check-db script.

This commit is contained in:
Mike Cao 2022-06-22 12:12:22 -07:00
parent c246b88329
commit 89fb62a50a
3 changed files with 31 additions and 25 deletions

View file

@ -5,6 +5,11 @@ const chalk = require('chalk');
const spawn = require('cross-spawn');
let message = '';
const updateMessage = `To update your database, you need to run:\n${chalk.bold.whiteBright(
'yarn update-db',
)}`;
const baselineMessage = cmd =>
`You need to update your database by running:\n${chalk.bold.whiteBright(cmd)}`;
function success(msg) {
console.log(chalk.greenBright(`${msg}`));
@ -34,9 +39,8 @@ async function checkTables() {
success('Database tables found.');
} catch (e) {
message = `To update your database, you need to run:\n${chalk.bold.whiteBright(
'yarn update-db',
)}`;
message = updateMessage;
throw new Error('Database tables not found.');
}
}
@ -65,10 +69,12 @@ async function checkMigrations() {
if (notManaged) {
const cmd = output.match(/yarn prisma migrate resolve --applied ".*"/g);
message = `You need to update your database by running:\n${chalk.bold.whiteBright(cmd[0])}`;
message = baselineMessage(cmd[0]);
throw new Error('Database is out of date.');
} else if (missingMigrations) {
message = output;
message = updateMessage;
throw new Error('Database is out of date.');
}