Skip to content

Commit

Permalink
fix: pending migrations check
Browse files Browse the repository at this point in the history
  • Loading branch information
tada5hi committed Dec 9, 2022
1 parent 79e2e02 commit 532cd2f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/database/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ export async function checkDatabase(context?: DatabaseCheckContext) : Promise<Da
return result;
}

const queryRunner = dataSource.createQueryRunner();

if (
dataSource.migrations &&
dataSource.migrations.length > 0
) {
const migrationExecutor = new MigrationExecutor(dataSource);
const migrationExecutor = new MigrationExecutor(dataSource, queryRunner);
result.migrationsPending = await migrationExecutor.getPendingMigrations();

if (result.migrationsPending.length === 0) {
result.schema = true;
}
} else {
const queryRunner = dataSource.createQueryRunner();

let schema : string | undefined;
if (hasStringProperty(dataSource.driver.options, 'schema')) {
schema = dataSource.driver.options.schema;
Expand All @@ -93,10 +93,10 @@ export async function checkDatabase(context?: DatabaseCheckContext) : Promise<Da

result.schema = tables.length === dataSource.entityMetadatas.length;
}

await queryRunner.release();
}

await queryRunner.release();

if (!dataSourceExisted) {
if (context.dataSourceCleanup) {
await dataSource.destroy();
Expand Down

0 comments on commit 532cd2f

Please sign in to comment.