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
179
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 2.13.2 to 2.14.0

bin/node-pg-migrate

13

CHANGELOG.md
# Change Log
## [2.14.0] (2017-11-14)
### Added
- Deferrable column constraints [#139](https://github.com/salsita/node-pg-migrate/pull/139)
- Possibility to use function in multi-column index [#140](https://github.com/salsita/node-pg-migrate/pull/140)
### Changed
- Changed all references from pg-migrate to node-pg-migrate [#141](https://github.com/salsita/node-pg-migrate/pull/141)
!!! Breaking change from version 3 !!! (now with warning)
## [2.13.2] (2017-11-03)

@@ -4,0 +17,0 @@

17

dist/operations/indexes.js

@@ -21,13 +21,10 @@ 'use strict';

function generateColumnString(column) {
return (/.+\(.*\)/.test(column) ? column // expression
: _utils.template`"${column}"`
); // single column
}
function generateColumnsString(columns) {
if (_lodash2.default.isArray(columns)) {
return columns.map(function (name) {
return _utils.template`"${name}"`;
}).join(', ');
}
if (/.+\(.*\)/.test(columns)) {
// expression
return columns;
}
return _utils.template`"${columns}"`; // single column
return _lodash2.default.isArray(columns) ? columns.map(generateColumnString).join(', ') : generateColumnString(columns);
}

@@ -34,0 +31,0 @@

@@ -45,2 +45,9 @@ 'use strict';

var parseDeferrable = function parseDeferrable(options) {
var deferrable = options.deferrable,
deferred = options.deferred;
return deferrable ? `DEFERRABLE INITIALLY ${deferred ? 'DEFERRED' : 'IMMEDIATE'}` : null;
};
var parseColumns = function parseColumns(columns) {

@@ -73,3 +80,4 @@ var extending_type_shorthands = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

check = options.check,
references = options.references;
references = options.references,
deferrable = options.deferrable;

@@ -98,2 +106,5 @@ var constraints = [];

}
if (deferrable) {
constraints.push(parseDeferrable(options));
}

@@ -114,4 +125,3 @@ var constraintsString = constraints.length ? ` ${constraints.join(' ')}` : '';

exclude = options.exclude,
deferrable = options.deferrable,
deferred = options.deferred;
deferrable = options.deferrable;

@@ -150,3 +160,3 @@ var table_name = typeof table === 'object' ? table.name : table;

if (deferrable) {
constraints.push(`DEFERRABLE INITIALLY ${deferred ? 'DEFERRED' : 'IMMEDIATE'}`);
constraints.push(parseDeferrable(options));
}

@@ -153,0 +163,0 @@

@@ -9,3 +9,4 @@ {

"bin": {
"pg-migrate": "bin/pg-migrate"
"pg-migrate": "bin/pg-migrate",
"node-pg-migrate": "bin/node-pg-migrate"
},

@@ -32,3 +33,3 @@ "main": "dist/runner.js",

],
"version": "2.13.2",
"version": "2.14.0",
"engines": {

@@ -79,3 +80,3 @@ "node": ">=4.0.0"

"test": "cross-env NODE_ENV=test mocha --opts ./mocha.opts test",
"lint": "eslint -c .eslintrc . bin/pg-migrate",
"lint": "eslint -c .eslintrc . bin/*",
"lintfix": "npm run lint -- --fix",

@@ -82,0 +83,0 @@ "prepare": "npm run compile"

@@ -1,2 +0,2 @@

# pg-migrate
# node-pg-migrate

@@ -18,3 +18,3 @@ [![Dependency Status](https://img.shields.io/david/salsita/node-pg-migrate.svg)](https://david-dm.org/salsita/node-pg-migrate)

Installing this module adds a runnable file into your `node_modules/.bin` directory. If installed globally (with the -g option), you can run `pg-migrate` and if not, you can run `./node_modules/.bin/pg-migrate`
Installing this module adds a runnable file into your `node_modules/.bin` directory. If installed globally (with the -g option), you can run `node-pg-migrate` and if not, you can run `./node_modules/.bin/node-pg-migrate`

@@ -66,3 +66,3 @@ ## Usage

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.
If a .env file exists, it will be loaded using [dotenv](https://www.npmjs.com/package/dotenv) (if installed) when running the node-pg-migrate binary.

@@ -73,14 +73,14 @@ 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.

- `pg-migrate create {migration-name}` - creates a new migration file with the name you give it. Spaces and underscores will be replaced by dashes and a timestamp is prepended to your file name.
- `pg-migrate up` - runs all up migrations from the current state.
- `pg-migrate up {N}` - runs N up migrations from the current state.
- `pg-migrate down` - runs a single down migration.
- `pg-migrate down {N}` - runs N down migrations from the current state.
- `pg-migrate unlock` - unlocks migrations (if previous up/down migration failed and was not automatically unlocked).
- `pg-migrate redo` - redoes last migration (runs a single down migration, then single up migration).
- `pg-migrate redo {N}` - redoes N last migrations (runs N down migrations, then N up migrations).
- `node-pg-migrate create {migration-name}` - creates a new migration file with the name you give it. Spaces and underscores will be replaced by dashes and a timestamp is prepended to your file name.
- `node-pg-migrate up` - runs all up migrations from the current state.
- `node-pg-migrate up {N}` - runs N up migrations from the current state.
- `node-pg-migrate down` - runs a single down migration.
- `node-pg-migrate down {N}` - runs N down migrations from the current state.
- `node-pg-migrate unlock` - unlocks migrations (if previous up/down migration failed and was not automatically unlocked).
- `node-pg-migrate redo` - redoes last migration (runs a single down migration, then single up migration).
- `node-pg-migrate redo {N}` - redoes N last migrations (runs N down migrations, then N up migrations).
### Configuration
You can adjust defaults by passing arguments to `pg-migrate`:
You can adjust defaults by passing arguments to `node-pg-migrate`:

@@ -98,3 +98,3 @@ * `config-file` (`f`) - The file with migration JSON config (defaults to undefined)

See all by running `pg-migrate --help`.
See all by running `node-pg-migrate --help`.

@@ -104,3 +104,3 @@ Most of configuration options can be also specified in [config](https://www.npmjs.com/package/config) 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`.
e.g. `PGSSLMODE=require pg-migrate up` ([pg](https://github.com/brianc/node-postgres/blob/master/CHANGELOG.md#v260) will take it into account)
e.g. `PGSSLMODE=require node-pg-migrate up` ([pg](https://github.com/brianc/node-postgres/blob/master/CHANGELOG.md#v260) will take it into account)

@@ -124,6 +124,6 @@ #### JSON Configuration

`pg-migrate` automatically checks if no other migration is running. To do so, it locks the migration table and enters comment there.
`node-pg-migrate` automatically checks if no other migration is running. To do so, it locks the migration table and enters comment there.
There are other options how to do it, but I choose this one (see #88).
In some circumstances it is possible that lock will not be released (Error message - `Error: Unable to fetch migrations: Error: Another migration is already running`).
In that case you need to run `pg-migrate unlock` to release the lock again.
In that case you need to run `node-pg-migrate unlock` to release the lock again.

@@ -133,3 +133,3 @@

When you run `pg-migrate create` a new migration file is created that looks like this:
When you run `node-pg-migrate create` a new migration file is created that looks like this:

@@ -152,3 +152,3 @@ ```javascript

If `exports.down` is not present in a migration, pg-migrate will try to automatically infer the operations that make up the down migration by reversing the operations of the up migration. Only some operations have automatically inferrable equivalents (details below on each operation). Sometimes, migrations are destructive and cannot be rolled back. In this case, you can set `exports.down = false` to tell pg-migrate that the down migration is impossible.
If `exports.down` is not present in a migration, node-pg-migrate will try to automatically infer the operations that make up the down migration by reversing the operations of the up migration. Only some operations have automatically inferrable equivalents (details below on each operation). Sometimes, migrations are destructive and cannot be rolled back. In this case, you can set `exports.down = false` to tell node-pg-migrate that the down migration is impossible.

@@ -204,4 +204,4 @@ #### Async Migrations

- `exclude` _[string]_ - sql for an exclude constraint
- `deferrable` _[boolean]_ - flag for deferrable table
- `deferred` _[boolean]_ - flag for initially deferred deferrable table
- `deferrable` _[boolean]_ - flag for deferrable table constraint
- `deferred` _[boolean]_ - flag for initially deferred deferrable table constraint
- `foreignKeys` _[object or array of objects]_ - foreign keys specification

@@ -722,2 +722,4 @@ - `columns` _[string or array of strings]_ - names of columns

- `match` _[string]_ - `FULL` or `SIMPLE`
- `deferrable` _[boolean]_ - flag for deferrable column constraint
- `deferred` _[boolean]_ - flag for initially deferred deferrable column constraint

@@ -724,0 +726,0 @@ #### Data types & Convenience Shorthand

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