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

Commit ad3de548 by Meg Sharkey

Merge remote-tracking branch 'sequelize/master'

2 parents a22ea8ec 2d3cdc4d
# v1.3.1 # # v1.3.1 #
- [REFACTORING] renamed ModelManager to ModelFactoryManager - [REFACTORING] renamed ModelManager to ModelFactoryManager
- [IMPROVEMENT] decreased delay of CustomEventEmitter execution from 5ms to 1ms
- [IMPROVEMENT] improved performance of association handling (many-to-many) (thanks to magshark)
- [FEATURE] added possibility to specify name of the join table (thanks to magshark)
- [FEATURE] mysql is emitting a 'sql'-event when executing a query
- [BUG] correctly delete existing SequelizeMeta entry from database after undoing migration
- [BUG] fix path of migration files in executable
# v1.3.0 # # v1.3.0 #
- [REFACTORING] Model#all is now a function and not a getter. - [REFACTORING] Model#all is now a function and not a getter.
......
...@@ -36,9 +36,12 @@ module.exports = (function() { ...@@ -36,9 +36,12 @@ module.exports = (function() {
emitter.emit('failure', err) emitter.emit('failure', err)
} else { } else {
var chainer = new Utils.QueryChainer var chainer = new Utils.QueryChainer
, from = migrations[0]
if(options.method == 'down') if(options.method == 'down') {
migrations.reverse() migrations.reverse()
from = migrations[0]
}
migrations.forEach(function(migration) { migrations.forEach(function(migration) {
chainer.add(migration, 'execute', [options], { chainer.add(migration, 'execute', [options], {
...@@ -51,7 +54,10 @@ module.exports = (function() { ...@@ -51,7 +54,10 @@ module.exports = (function() {
console.log('Executed migration: ' + migration.filename) console.log('Executed migration: ' + migration.filename)
}, },
success: function(migration, callback) { success: function(migration, callback) {
saveSuccessfulMigration.call(self, migrations[0], migration, callback) if(options.method == 'down')
deleteUndoneMigration.call(self, from, migration, callback)
else
saveSuccessfulMigration.call(self, from, migration, callback)
} }
}) })
}) })
...@@ -195,5 +201,17 @@ module.exports = (function() { ...@@ -195,5 +201,17 @@ module.exports = (function() {
}) })
} }
var deleteUndoneMigration = function(from, to, callback) {
var self = this
self.findOrCreateSequelizeMetaModel().success(function(SequelizeMeta) {
SequelizeMeta
.find({ from: from.migrationId, to: to.migrationId })
.success(function(meta) {
meta.destroy().success(callback)
})
})
}
return Migrator return Migrator
})() })()
{ {
"name": "sequelize", "name": "sequelize",
"description": "MySQL ORM for Node.JS", "description": "MySQL ORM for Node.JS",
"version": "1.3.0", "version": "1.3.1",
"author": "Sascha Depold <sascha@depold.com>", "author": "Sascha Depold <sascha@depold.com>",
"contributors": [ "contributors": [
{ "name": "Sascha Depold", "email": "sascha@depold.com" } { "name": "Sascha Depold", "email": "sascha@depold.com" },
{ "name": "Meg Sharkey" }
], ],
"dependencies": { "dependencies": {
"mysql": "0.9.x", "mysql": "0.9.x",
...@@ -29,4 +30,4 @@ ...@@ -29,4 +30,4 @@
"node": ">=0.4.6" "node": ">=0.4.6"
}, },
"license": "MIT" "license": "MIT"
} }
\ No newline at end of file
module.exports = { module.exports = {
username: "meg", username: "root",
password: "meg", password: null,
database: 'test', database: 'sequelize_test',
host: '127.0.0.1', host: '127.0.0.1',
rand: function() { rand: function() {
return parseInt(Math.random() * 999) return parseInt(Math.random() * 999)
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!