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 1.1.0 to 1.2.0

55

lib/runner.js

@@ -77,16 +77,7 @@ var async = require('async');

var doneMigrations = [];
var runMigrations = [];
// filter out undone and done migrations from list of files
for (var i = 0; i < migrations.length; i++) {
if (runNames.indexOf(migrations[i].name) < 0) {
// if specific migration file is requested
if (options.file && options.file === migrations[i].name) {
runMigrations = [ migrations[i] ];
break;
if (options.checkOrder) {
for (var i = 0; i < runNames.length; i++) {
if (runNames[i] !== migrations[i].name) {
return exitCallback(new Error('Not run migration ' + migrations[i].name + ' is preceding already run migration ' + runNames[i]));
}
runMigrations.push(migrations[i]);
} else {
doneMigrations.push(migrations[i]);
}

@@ -98,22 +89,28 @@ }

// down gets by default one migration at the time, if not set otherwise
if (options.direction === 'down') {
to_run = doneMigrations.slice(-1);
// up gets all undone migrations by default
to_run = runNames
.filter(function(migration_name) {
return !options.file || options.file === migration_name;
})
.map(function(migration_name) {
return migrations.find(function(migration) {
return migration.name === migration_name;
}) || migration_name;
})
.slice(-Math.abs(options.count || 1))
.reverse();
var deletedMigrations = to_run.filter(function(migration) {
return typeof migration === 'string';
});
if (deletedMigrations.length) {
return exitCallback(new Error('Definitions of migrations ' + deletedMigrations.join(', ') + ' have been deleted.'));
}
} else {
to_run = runMigrations;
to_run = migrations
.filter(function(migration) {
return runNames.indexOf(migration.name) < 0 && (!options.file || options.file === migration.name);
})
.slice(0, Math.abs(options.count || Infinity));
}
// if specific count of migrations is requested
if (options.count) {
// infinity is set in the bin file
if (options.count !== Infinity) {
if (options.direction === 'up') {
to_run = runMigrations.slice(0, options.count);
} else {
to_run = doneMigrations.slice(options.count * -1).reverse();
}
}
}
if (!to_run.length) {

@@ -120,0 +117,0 @@ console.log('No migrations to run!');

@@ -18,3 +18,3 @@ {

],
"version": "1.1.0",
"version": "1.2.0",
"engines": {

@@ -21,0 +21,0 @@ "node": ">=0.6.0"

@@ -35,2 +35,4 @@ # pg-migrate

* `check-order` - Check order of migrations before running them. (There should be no migration with timestamp lesser than last run migration.)
See all by running `pg-migrate --help`.

@@ -37,0 +39,0 @@

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