Created
December 5, 2016 18:03
-
-
Save mllrjb/edda2ac8cd28a370aa32abf0b4ce7012 to your computer and use it in GitHub Desktop.
Umzug Migration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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