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

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