Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-pg-migrate

Package Overview
Dependencies
Maintainers
3
Versions
180
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-pg-migrate - npm Package Compare versions

Comparing version 1.3.0 to 2.0.0-rc

.babelrc

31

package.json

@@ -21,5 +21,5 @@ {

],
"version": "1.3.0",
"version": "2.0.0-rc",
"engines": {
"node": ">=0.6.0"
"node": ">=4.0.0"
},

@@ -35,15 +35,20 @@ "bugs": {

"dependencies": {
"async": "~2.3.0",
"dotenv": "~4.0.0",
"lodash": "~4.17.0",
"mkdirp": "~0.5.1",
"yargs": "~7.1.0",
"step": "~1.0.0"
"yargs": "~7.1.0"
},
"devDependencies": {
"eslint": "^3.19.0",
"babel-cli": "^6.24.0",
"babel-eslint": "^7.2.0",
"babel-plugin-rewire": "^1.1.0",
"babel-preset-env": "^1.4.0",
"babel-preset-stage-3": "^6.24.0",
"config": ">=1.0.0",
"cross-env": "^4.0.0",
"dotenv": ">=1.0.0",
"eslint": "^3.17.0",
"eslint-config-airbnb-base": "11.1.3",
"eslint-plugin-import": "^2.2.0",
"mocha": "^3.2.0",
"pg": "^6.1.0",
"rewire": "^2.5.0",
"sinon": "^2.1.0"

@@ -54,7 +59,13 @@ },

},
"optionalDependencies": {
"config": ">=1.0.0",
"dotenv": ">=1.0.0"
},
"scripts": {
"test": "mocha test",
"compile": "babel lib/ -d dist/",
"test": "cross-env NODE_ENV=test mocha --compilers js:babel-core/register test",
"lint": "eslint -c .eslintrc . bin/pg-migrate",
"lintfix": "npm run lint -- --fix"
"lintfix": "npm run lint -- --fix",
"prepublish": "npm run compile"
}
}
# pg-migrate
[![Dependency Status](https://david-dm.org/theoephraim/node-pg-migrate.svg)](https://david-dm.org/theoephraim/node-pg-migrate)
[![devDependency Status](https://david-dm.org/theoephraim/node-pg-migrate/dev-status.svg)](https://david-dm.org/theoephraim/node-pg-migrate?type=dev)
[![peerDependencies Status](https://david-dm.org/theoephraim/node-pg-migrate/peer-status.svg)](https://david-dm.org/theoephraim/node-pg-migrate?type=peer)
[![Dependency Status](https://img.shields.io/david/theoephraim/node-pg-migrate.svg)](https://david-dm.org/theoephraim/node-pg-migrate)
[![devDependency Status](https://img.shields.io/david/dev/theoephraim/node-pg-migrate.svg)](https://david-dm.org/theoephraim/node-pg-migrate?type=dev)
[![peerDependencies Status](https://img.shields.io/david/peer/theoephraim/node-pg-migrate.svg)](https://david-dm.org/theoephraim/node-pg-migrate?type=peer)
[![optionalDependencies Status](https://img.shields.io/david/optional/theoephraim/node-pg-migrate.svg)](https://david-dm.org/theoephraim/node-pg-migrate?type=optional)
[![NPM version](https://img.shields.io/npm/v/node-pg-migrate.svg)](https://www.npmjs.com/package/node-pg-migrate)

@@ -20,5 +21,34 @@ ![Downloads](https://img.shields.io/npm/dm/node-pg-migrate.svg?style=flat)

You must specify your database connection url by setting the environment variable `DATABASE_URL`.
If a .env file exists, it will be loaded using [dotenv](https://github.com/motdotla/dotenv) when running the pg-migrate binary.
You can specify your database connection information using [config](https://www.npmjs.com/package/config).
```json
// config/default.json
{
"db": "postgres://postgres:password@localhost:5432/name"
}
```
or
```json
// config/default.json
{
"db": {
"user": "postgres",
"password": "",
"host": "localhost",
"port": 5432,
"name": "name"
}
}
```
You could also specify your database url by setting the environment variable `DATABASE_URL`.
```
DATABASE_URL=postgres://postgres@localhost/name node-pg-migrate
```
If a .env file exists, it will be loaded using [dotenv](https://www.npmjs.com/package/dotenv) (if installed) when running the pg-migrate binary.
Depending on your project's setup, it may make sense to write some custom grunt tasks that set this env var and run your migration commands. More on that below.

@@ -38,11 +68,15 @@

* `schema` (`s`) - The schema on which migration will be run (defaults to `public`)
* `database-url-var` (`d`) - Name of env variable with database url string (defaults to `DATABASE_URL`)
* `migrations-dir` (`m`) - The directory containing your migration files (defaults to `migrations`)
* `migrations-schema` (`s`) - The schema storing table which migrations have been run (defaults to `public`)
* `migrations-schema` - The schema storing table which migrations have been run (defaults to same value as `schema`)
* `migrations-table` (`t`) - The table storing which migrations have been run (defaults to `pgmigrations`)
* `check-order` - Check order of migrations before running them. (There should be no migration with timestamp lesser than last run migration.)
* `check-order` - Check order of migrations before running them (defaults to `true`, to switch it off supply `--no-check-order` on command line).
(There should be no migration with timestamp lesser than last run migration.)
See all by running `pg-migrate --help`.
Most of configuration options can be also specified in `node-config` configuration file.
For SSL connection to DB you can set `PGSSLMODE` environment variable to value from [list](https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNECT-SSLMODE) other then `disable`.

@@ -57,6 +91,6 @@ e.g. `PGSSLMODE=require pg-migrate up` ([pg](https://github.com/brianc/node-postgres/blob/master/CHANGELOG.md#v260) will take it into account)

```javascript
exports.up = function(pgm){
exports.up = function up(pgm) {
}
exports.down = function(pgm){
exports.down = function down(pgm) {

@@ -80,4 +114,4 @@ }

```javascript
exports.up = function(pgm, run){
doSomethingAsync(function(){
exports.up = function up(pgm, run) {
doSomethingAsync(function() {
run();

@@ -88,4 +122,14 @@ });

Another way how to perform some async operation is to return [Promise](https://promisesaplus.com/) from `up` or `down` function. Example:
```javascript
exports.up = function(pgm) {
return new Promise(resolve => {
// doSomethingAsync
resolve();
});
}
```
## Migration methods

@@ -102,3 +146,3 @@

> Create a new table - [postgres docs](http://www.postgresql.org/docs/9.3/static/sql-createtable.html)
> Create a new table - [postgres docs](http://www.postgresql.org/docs/current/static/sql-createtable.html)

@@ -117,3 +161,3 @@ **Arguments:**

> Drop existing table - [postgres docs](http://www.postgresql.org/docs/9.3/static/sql-droptable.html)
> Drop existing table - [postgres docs](http://www.postgresql.org/docs/current/static/sql-droptable.html)

@@ -127,3 +171,3 @@ **Arguments:**

> Rename a table - [postgres docs](http://www.postgresql.org/docs/9.3/static/sql-altertable.html)
> Rename a table - [postgres docs](http://www.postgresql.org/docs/current/static/sql-altertable.html)

@@ -140,3 +184,3 @@ **Arguments:**

> Add columns to an existing table - [postgres docs](http://www.postgresql.org/docs/9.3/static/sql-altertable.html)
> Add columns to an existing table - [postgres docs](http://www.postgresql.org/docs/current/static/sql-altertable.html)

@@ -154,3 +198,3 @@ **Arguments:**

> Drop columns from a table - [postgres docs](http://www.postgresql.org/docs/9.3/static/sql-altertable.html)
> Drop columns from a table - [postgres docs](http://www.postgresql.org/docs/current/static/sql-altertable.html)

@@ -167,3 +211,3 @@ **Arguments:**

> Rename a column - [postgres docs](http://www.postgresql.org/docs/9.3/static/sql-altertable.html)
> Rename a column - [postgres docs](http://www.postgresql.org/docs/current/static/sql-altertable.html)

@@ -181,3 +225,3 @@ **Arguments:**

> Alter a column (default value, type, allow null) - [postgres docs](http://www.postgresql.org/docs/9.3/static/sql-altertable.html)
> Alter a column (default value, type, allow null) - [postgres docs](http://www.postgresql.org/docs/current/static/sql-altertable.html)

@@ -196,3 +240,3 @@ **Arguments:**

> Add a named column constraint - [postgres docs](http://www.postgresql.org/docs/9.3/static/sql-altertable.html)
> Add a named column constraint - [postgres docs](http://www.postgresql.org/docs/current/static/sql-altertable.html)

@@ -211,3 +255,3 @@ **Arguments:**

> Drop a named column constraint - [postgres docs](http://www.postgresql.org/docs/9.3/static/sql-altertable.html)
> Drop a named column constraint - [postgres docs](http://www.postgresql.org/docs/current/static/sql-altertable.html)

@@ -222,3 +266,3 @@ **Arguments:**

> Create a new index - [postgres docs](http://www.postgresql.org/docs/9.3/static/sql-createindex.html)
> Create a new index - [postgres docs](http://www.postgresql.org/docs/current/static/sql-createindex.html)

@@ -242,3 +286,3 @@ **Arguments:**

> Drop an index - [postgres docs](http://www.postgresql.org/docs/9.3/static/sql-dropindex.html)
> Drop an index - [postgres docs](http://www.postgresql.org/docs/current/static/sql-dropindex.html)

@@ -267,3 +311,3 @@ **Arguments:**

> Install postgres extension(s) - [postgres docs](http://www.postgresql.org/docs/9.3/static/sql-createextension.html.html)
> Install postgres extension(s) - [postgres docs](http://www.postgresql.org/docs/current/static/sql-createextension.html.html)

@@ -280,3 +324,3 @@ **Arguments:**

> Un-install postgres extension(s) - [postgres docs](http://www.postgresql.org/docs/9.3/static/sql-dropextension.html)
> Un-install postgres extension(s) - [postgres docs](http://www.postgresql.org/docs/current/static/sql-dropextension.html)

@@ -291,3 +335,3 @@ **Arguments:**

> Create a new data type - [postgres docs](http://www.postgresql.org/docs/9.3/static/sql-createtype.html)
> Create a new data type - [postgres docs](http://www.postgresql.org/docs/current/static/sql-createtype.html)

@@ -305,3 +349,3 @@ **Arguments:**

> Drop a custom data type - [postgres docs](http://www.postgresql.org/docs/9.3/static/sql-droptype.html)
> Drop a custom data type - [postgres docs](http://www.postgresql.org/docs/current/static/sql-droptype.html)

@@ -308,0 +352,0 @@ **Arguments:**

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc