Skip to content

Commit

Permalink
ensure dataSource initialize before running migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
ae2079 committed Jul 31, 2024
1 parent 9d3823e commit b2678d6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/pre-test-scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ async function dropDatabaseAndCreateFreshOne() {
}

async function runMigrations() {
await (
await AppDataSource.initialize()
).runMigrations({
transaction: 'all',
});
console.log('Migrations has been executed successfully');
try {
const dataSource = await AppDataSource.initialize();
await dataSource.runMigrations({ transaction: 'all' });
console.log('Migrations have been executed successfully');
} catch (error) {
console.error('Error running migrations:', error);
process.exit(1);
}
}

const seedDb = async () => {
Expand Down

0 comments on commit b2678d6

Please sign in to comment.