Skip to content

Instantly share code, notes, and snippets.

@mllrjb
Created December 5, 2016 18:03
Show Gist options
  • Save mllrjb/edda2ac8cd28a370aa32abf0b4ce7012 to your computer and use it in GitHub Desktop.
Save mllrjb/edda2ac8cd28a370aa32abf0b4ce7012 to your computer and use it in GitHub Desktop.
Umzug Migration
const path = require('path')
, Umzug = require('umzug')
, Bluebird = require('bluebird')
const db = {
// sequelize instance
sequelize: null,
// Sequelize constructor
Sequelize: null
};
const migrator = new Umzug({
storage: 'sequelize',
storageOptions: {
sequelize: db.sequelize,
tableName: 'SequelizeMeta'
},
logging: function() {
console.log.apply(console, arguments);
},
migrations: {
params: [db.sequelize.getQueryInterface(), db.Sequelize],
path: path.join(__dirname, '/migrations'),
pattern: /\.js$/,
wrap: function(cb) {
// from sequelize-cli/lib/tasks/db.js#getMigrator
if (cb.length === 3) {
return Bluebird.promisify(cb);
} else {
return cb;
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment