Skip to content

Commit

Permalink
add deploy if missing migrations. add logic to hand 01_init
Browse files Browse the repository at this point in the history
  • Loading branch information
briancao committed Jul 26, 2022
1 parent 6890912 commit c7476aa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scripts/check-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,17 @@ async function checkMigrations() {
const output = await run('prisma', ['migrate', 'status']);

const missingMigrations = output.includes('have not yet been applied');
const missingInitialMigration = output.includes('01_init');
const notManaged = output.includes('The current database is not managed');

if (notManaged || missingMigrations) {
console.log('Running update...');

console.log(execSync('prisma migrate resolve --applied "01_init"').toString());
if (missingInitialMigration) {
console.log(execSync('prisma migrate resolve --applied "01_init"').toString());
}

console.log(execSync('prisma migrate deploy').toString());
}

success('Database is up to date.');
Expand Down

0 comments on commit c7476aa

Please sign in to comment.