
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
db-migrate-boilerplate
Advanced tools
Reduce the amount of boilerplate in your project needed to support raw SQL migrations using db-migrate.
Reduce the amount of boilerplate in your project needed to support raw SQL migrations using db-migrate.
Install via npm:
$ npm install db-migrate-boilerplate
Replace the default migration handler generated by db-migrate with this:
'use strict'
const path = require('path')
const boilerplate = require('db-migrate-boilerplate')
module.exports = boilerplate({
// TODO replace with your correct paths
upPath: path.join(__dirname, 'sqls', '20161226111110-test-up.sql'),
downPath: path.join(__dirname, 'sqls', '20161226111110-test-down.sql')
})
Make sure to replace the paths with your expected values.
db-migrate generates a lot of boilerplate code when creating a raw SQL migration. Here is an example:
'use strict';
var dbm;
var type;
var seed;
var fs = require('fs');
var path = require('path');
var Promise;
/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function(options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
Promise = options.Promise;
};
exports.up = function(db) {
var filePath = path.join(__dirname, 'sqls', '20161226111110-test-up.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
if (err) return reject(err);
console.log('received data: ' + data);
resolve(data);
});
})
.then(function(data) {
return db.runSql(data);
});
};
exports.down = function(db) {
var filePath = path.join(__dirname, 'sqls', '20161226111110-test-down.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
if (err) return reject(err);
console.log('received data: ' + data);
resolve(data);
});
})
.then(function(data) {
return db.runSql(data);
});
};
exports._meta = {
"version": 1
};
MIT
FAQs
Reduce the amount of boilerplate in your project needed to support raw SQL migrations using db-migrate.
The npm package db-migrate-boilerplate receives a total of 7 weekly downloads. As such, db-migrate-boilerplate popularity was classified as not popular.
We found that db-migrate-boilerplate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.