Socket
Socket
Sign inDemoInstall

loopback-component-migrate

Package Overview
Dependencies
426
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.4 to 0.2.0

44

lib/models/migration.js

@@ -48,2 +48,46 @@ 'use strict';

/**
* Remote Method: Run specific migration by name.
*
* @param {String} [name] Name of migration script to run.
* @param {String} [record] Record the migration runtime to database.
* @param {Function} [cb] Callback function.
*/
Migration.migrateByName = function(name, record, cb) {
if (typeof cb === 'undefined' && typeof record === 'function') {
cb = record;
record = false;
}
record = record || false;
cb = cb || utils.createPromiseCallback();
assert(typeof name === 'string', 'The to argument must be a string, not ' + typeof name);
assert(typeof cb === 'function', 'The cb argument must be a function, not ' + typeof cb);
Migration.log.info(name, 'running.');
const scriptPath = path.resolve(path.join(Migration.migrationsDir, name));
try {
require(scriptPath).up(Migration.app, function(err) {
if (err) {
Migration.log.error(`Error running migration script ${name}:`, err);
Migration.finish(err);
return cb(err);
} else if (record) {
Migration.create({
name: name,
runDtTm: new Date()
});
}
cb();
});
} catch (err) {
Migration.log.error(`Error running migration script ${name}:`, err);
Migration.finish(err);
cb(err);
}
return cb.promise;
};
/**
* Run migrations (up or down).

@@ -50,0 +94,0 @@ *

@@ -37,2 +37,21 @@ {

},
"migrateByName": {
"description": "Run specific migration by name",
"isStatic": true,
"http": {
"path": "/migrateByName",
"verb": "get"
},
"accepts": [{
"arg": "name",
"type": "String",
"required": true,
"description": "Name of the migration script to run."
},
{
"arg" : "record",
"type" : "boolean",
"required" : false
}]
},
"rollbackTo": {

@@ -39,0 +58,0 @@ "description": "Rollback migrations",

4

package.json
{
"name": "loopback-component-migrate",
"version": "0.1.4",
"version": "0.2.0",
"description": "Migration framework for Loopback.",

@@ -87,2 +87,2 @@ "author": {

}
}
}
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