Skip to content

Commit

Permalink
🎨 chore: improve migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Aug 3, 2024
1 parent 86526ef commit 1e1380e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scripts/migrateServerDB/docker.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,23 @@ const client = new Pool({ connectionString: process.env.DATABASE_URL });
const db = drizzle(client);

const runMigrations = async () => {
console.log('[Database] Start to migration...');
await migrator.migrate(db, {
migrationsFolder: join(__dirname, './migrations'),
});

console.log('✅ database migration pass.');
console.log('-------------------------------------');
// eslint-disable-next-line unicorn/no-process-exit
process.exit(0);
};

// eslint-disable-next-line unicorn/prefer-top-level-await
runMigrations().catch((err) => {
console.error('❌ Database migrate failed:', err);
console.error(
'❌ Database migrate failed. Please check your database is valid and DATABASE_URL is set correctly. The error detail is below:',
);
console.error(err);
// eslint-disable-next-line unicorn/no-process-exit
process.exit(1);
});

0 comments on commit 1e1380e

Please sign in to comment.