node-pg-migrate
Advanced tools
Comparing version 4.5.0 to 4.5.1
# Change Log | ||
## [4.5.1](2020-04-03) | ||
### Fixed | ||
- Do provide default cli option value only if not specified [#588](https://github.com/salsita/node-pg-migrate/pull/588) | ||
- Fix locking [#586](https://github.com/salsita/node-pg-migrate/pull/586) | ||
## [4.5.0](2020-04-01) | ||
@@ -4,0 +11,0 @@ |
@@ -34,7 +34,13 @@ "use strict"; | ||
const lock = async (db) => { | ||
const [lockObtained] = await db.select(`select pg_try_advisory_lock(${PG_MIGRATE_LOCK_ID}) as "lockObtained"`); | ||
if (!lockObtained) { | ||
const [result] = await db.select(`select pg_try_advisory_lock(${PG_MIGRATE_LOCK_ID}) as "lockObtained"`); | ||
if (!result.lockObtained) { | ||
throw new Error('Another migration is already running'); | ||
} | ||
}; | ||
const unlock = async (db) => { | ||
const [result] = await db.select(`select pg_advisory_unlock(${PG_MIGRATE_LOCK_ID}) as "lockReleased"`); | ||
if (!result.lockReleased) { | ||
throw new Error('Failed to release migration lock'); | ||
} | ||
}; | ||
const ensureMigrationsTable = async (db, options) => { | ||
@@ -173,4 +179,7 @@ try { | ||
finally { | ||
if (!options.noLock) { | ||
await unlock(db).catch((error) => logger.warn(error.message)); | ||
} | ||
db.close(); | ||
} | ||
}; |
{ | ||
"name": "node-pg-migrate", | ||
"version": "4.5.0", | ||
"version": "4.5.1", | ||
"description": "Postgresql database migration management tool for node.js", | ||
@@ -5,0 +5,0 @@ "author": "Theo Ephraim", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
268991
3288