Skip to content

Commit

Permalink
Fix DB connect and generator for migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
mde committed Nov 19, 2013
1 parent fbb0a1c commit 38028ae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
30 changes: 21 additions & 9 deletions gen/jakelib/env.jake
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,29 @@ namespace('env', function () {
});
});

task('cleanup', function () {
task('cleanup', {async: true}, function () {
// Disconnect all the adapters
var adapters = geddy.model.loadedAdapters
, adapter;

for (var p in adapters) {
adapter = adapters[p];
if (typeof adapter.disconnect == 'function') {
adapter.disconnect();
}
}
, adapter
, keys = Object.keys(adapters)
, doIt = function () {
var key;
if ((key = keys.shift())) {
adapter = adapters[key];
// Try to disconnect nicely
if (typeof adapter.disconnect == 'function') {
// If there's a disconnect error, don't flip out about it
adapter.on('error', function () {});
adapter.disconnect(function () {
doIt();
});
}
}
else {
complete();
}
};
doIt();
});

});
Expand Down
4 changes: 2 additions & 2 deletions gen/jakelib/migration.jake
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ namespace('migration', function () {
// Hook up the DB adapter
// TODO: API for using a different adapter if using multiple
// SQL adapters?
inst.adapter = geddy.model.loadedAdapters.Migration;
// Run it, up or down
Migration.call(inst, ctorName, geddy.model.loadedAdapters.Migration);
inst[direction](function () {
var m;
// Run it, up or down
if (direction == 'up') {
m = geddy.model.Migration.create({
migration: migration
Expand Down

0 comments on commit 38028ae

Please sign in to comment.