Socket
Socket
Sign inDemoInstall

sql-migrations

Package Overview
Dependencies
60
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.4 to 1.0.5

adapters/mysql.js

4

commands/create-migration-command.js

@@ -9,2 +9,6 @@ var fs = require('fs'),

if (typeof config.migrationsDir !== 'string') {
throw new Error('configuration "migrationsDir" is missing');
}
mkdirp.sync(config.migrationsDir);

@@ -11,0 +15,0 @@

8

commands/run-migrations-command.js
var chalk = require('chalk');
module.exports = function (migrationProvider, adapter, logger) {
module.exports = function (migrationProvider, adapter, minMigrationTime, logger) {
return adapter.appliedMigrations()
.then(function (appliedMigrationIds) {
var migrationsList = migrationProvider.getMigrationsList();
var pending = getPending(migrationsList, appliedMigrationIds);
var pending = getPending(migrationsList, appliedMigrationIds, minMigrationTime);

@@ -33,7 +33,7 @@ if (pending.length === 0) {

function getPending(migrationsList, appliedMigrationIds) {
function getPending(migrationsList, appliedMigrationIds, minMigrationTime) {
var pending = [];
migrationsList.forEach(function (migration) {
var id = migration.match(/^(\d+)/)[0];
if (!~appliedMigrationIds.indexOf(id) && migration.match(/^\d+\_up.*$/)) {
if ((!minMigrationTime || id >= minMigrationTime) && !~appliedMigrationIds.indexOf(id) && migration.match(/^\d+\_up.*$/)) {
pending.push(migration);

@@ -40,0 +40,0 @@ }

var MigrationProvider = require('./migration-provider');
var PgAdapter = require('./adapters/pg');
var createMigrationCommand = require('./commands/create-migration-command');
var runMigrationsCommand = require('./commands/run-migrations-command')
var runMigrationsCommand = require('./commands/run-migrations-command');
var rollbackMigrationCommand = require('./commands/rollback-migration-command');

@@ -9,6 +8,5 @@

function migrate(config) {
function migrate(config, adapter) {
var migrationProvider = MigrationProvider(config);
var adapter = PgAdapter(config, LOGGER);
return runMigrationsCommand(migrationProvider, adapter, LOGGER).then(function () {
return runMigrationsCommand(migrationProvider, adapter, config.minMigrationTime, LOGGER).then(function () {
return adapter.dispose();

@@ -23,5 +21,4 @@ }, function (error) {

function rollback(config) {
function rollback(config, adapter) {
var migrationProvider = MigrationProvider(config);
var adapter = PgAdapter(config, LOGGER);
return rollbackMigrationCommand(migrationProvider, adapter, LOGGER).then(function () {

@@ -44,2 +41,7 @@ return adapter.dispose();

run: function (config) {
config.adapter = config.adapter || 'pg';
var Adapter = require('./adapters/' + config.adapter);
var adapter = Adapter(config, LOGGER);
var args = process.argv.slice(2);

@@ -52,6 +54,6 @@

case 'migrate':
migrate(config).then(onCliSuccess, onCliError);
migrate(config, adapter).then(onCliSuccess, onCliError);
break;
case 'rollback':
rollback(config).then(onCliSuccess, onCliError);
rollback(config, adapter).then(onCliSuccess, onCliError);
break;

@@ -58,0 +60,0 @@ default:

{
"name": "sql-migrations",
"version": "1.0.4",
"version": "1.0.5",
"description": "raw SQL migrations library for Node.js",

@@ -24,4 +24,5 @@ "main": "index.js",

"mkdirp": "^0.5.0",
"promise-mysql": "^3.3.1",
"pg": "^7.4.1"
}
}

@@ -69,6 +69,8 @@ node-sql-migrations

password: 'password', // Database password
adapter: 'pg', // Database adapter: pg, mysql
// Parameters are optional. If you provide them then any occurrences of the parameter (i.e. FOO) in the SQL scripts will be replaced by the value (i.e. bar).
parameters: {
"FOO": "bar"
}
},
minMigrationTime: new Date('2018-01-01').getTime() // Optional. Skip migrations before this before this time.
};

@@ -75,0 +77,0 @@ ```

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc