Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for ES Module detection using npm@7 (#4295) #4296

Merged
merged 6 commits into from
Feb 15, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 19 additions & 10 deletions lib/migrations/migrate/Migrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,16 @@ class Migrator {

const transactionForAll =
!this.config.disableTransactions &&
!migrations.some((migration) => {
const migrationContents = this.config.migrationSource.getMigration(
migration
);
return !this._useTransaction(migrationContents);
});
!(
await Promise.all(
migrations.map(async (migration) => {
const migrationContents = await this.config.migrationSource.getMigration(
migration
);
return !this._useTransaction(migrationContents);
})
)
).some((e) => e);
richardsimko marked this conversation as resolved.
Show resolved Hide resolved

if (transactionForAll) {
return this.knex.transaction((trx) => {
Expand Down Expand Up @@ -133,17 +137,22 @@ class Migrator {
migrationToRun = newMigrations[0];
}

return {
migrationToRun,
useTransaction: this._useTransaction(
this.config.migrationSource.getMigration(migrationToRun)
),
};
})
.then(({ migrationToRun, useTransaction }) => {
const migrationsToRun = [];
if (migrationToRun) {
migrationsToRun.push(migrationToRun);
}

const transactionForAll =
!this.config.disableTransactions &&
(!migrationToRun ||
this._useTransaction(
this.config.migrationSource.getMigration(migrationToRun)
));
(!migrationToRun || useTransaction);

if (transactionForAll) {
return this.knex.transaction((trx) => {
Expand Down