https://github.com/one-com/node-postgres-migrate
Postgres migrations from node.js with advisory locks.
https://github.com/one-com/node-postgres-migrate
Last synced: about 2 months ago
JSON representation
Postgres migrations from node.js with advisory locks.
- Host: GitHub
- URL: https://github.com/one-com/node-postgres-migrate
- Owner: One-com
- License: bsd-3-clause
- Created: 2015-12-28T13:11:55.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-08T14:39:11.000Z (about 9 years ago)
- Last Synced: 2025-02-05T07:49:09.704Z (4 months ago)
- Language: JavaScript
- Size: 21.5 KB
- Stars: 4
- Watchers: 11
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# postgres-migrate
[](https://www.npmjs.com/package/postgres-migrate)
[](https://travis-ci.org/One-com/node-postgres-migrate)Migrations for PostgreSQL databases utilizing advisory locks.
# Usage
Keep your migration files in a separate folder, as individual `.sql` files.
```js
var migrate = require('postgres-migrate');migrate({
conString: 'postgres://dbuser:dbpass@dbhost:32321/dbname',
migrationsDir: 'path/to/migrationsDirectory',
reporter: console.log.bind(console) // optional parameter
}).then(function () {
// The database is ready to be used!
}).catch(function (err) {
// Something bad happened!
});
```You can safely start multiple workers at the same time. Only one of them will
take the lock, and upgrade the database. The others will wait for the migration
to be completed, and then resolve the promise.