不要怂,就是干,撸起袖子干!

Commit f4b8b1bb by Mick Hansen

wrap undo/migrate in an authenticate call and log error

1 parent 9a0b38ac
Showing with 23 additions and 19 deletions
...@@ -229,27 +229,31 @@ if (program.migrate || program.undo) { ...@@ -229,27 +229,31 @@ if (program.migrate || program.undo) {
migratorOptions = _.merge(migratorOptions, { filesFilter: /\.js$|\.coffee$/ }) migratorOptions = _.merge(migratorOptions, { filesFilter: /\.js$|\.coffee$/ })
} }
var migrator = sequelize.getMigrator(migratorOptions) sequelize.authenticate().success(function () {
var migrator = sequelize.getMigrator(migratorOptions)
if (program.undo) {
migrator.findOrCreateSequelizeMetaDAO().success(function(Meta) { if (program.undo) {
Meta.find({ order: 'id DESC' }).success(function(meta) { migrator.findOrCreateSequelizeMetaDAO().success(function(Meta) {
if (meta) { Meta.find({ order: 'id DESC' }).success(function(meta) {
migrator = sequelize.getMigrator(_.extend(migratorOptions, meta.values), true) if (meta) {
migrator.migrate({ method: 'down' }).success(function() { migrator = sequelize.getMigrator(_.extend(migratorOptions, meta.values), true)
migrator.migrate({ method: 'down' }).success(function() {
process.exit(0)
})
} else {
console.log("There are no pending migrations.")
process.exit(0) process.exit(0)
}) }
} else { })
console.log("There are no pending migrations.")
process.exit(0)
}
}) })
}) } else {
} else { sequelize.migrate().success(function() {
sequelize.migrate().success(function() { process.exit(0)
process.exit(0) })
}) }
} }).error(function (err) {
console.error("Unable to connect to database: "+err)
})
} else { } else {
console.log('Cannot find "' + configuration.configFile + '". Have you run "sequelize --init"?') console.log('Cannot find "' + configuration.configFile + '". Have you run "sequelize --init"?')
process.exit(1) process.exit(1)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!