
Product
Socket Now Supports pylock.toml Files
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
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 0 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 now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.
Research
Security News
Malicious Ruby gems typosquat Fastlane plugins to steal Telegram bot tokens, messages, and files, exploiting demand after Vietnam’s Telegram ban.