Skip to content

Commit

Permalink
[bugfix] internal linking causes infinite loop
Browse files Browse the repository at this point in the history
fixes #329
  • Loading branch information
wzrdtales committed Dec 3, 2015
1 parent 9fd09d7 commit c0fb2ae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
17 changes: 6 additions & 11 deletions connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ var log = require('./lib/log');
var internals = {};

exports.connect = function(config, passedClass, callback) {
var internals = {},
_config = config;
var internals = {};

if( config.config ) {
internals = config.internals;
Expand Down Expand Up @@ -59,7 +58,8 @@ exports.connect = function(config, passedClass, callback) {

files.push('');

db.close = function(cb) { migrationFiles(files, callback, _config, passedClass, db, oldClose, cb); };
db.close = function(cb) { migrationFiles(files, callback, config,
internals, passedClass, db, oldClose, cb); };

db.close();
});
Expand All @@ -83,25 +83,20 @@ exports.driver = function(config, callback) {
driver.connect(config, internals, callback);
};

function migrationFiles(files, callback, config, passedClass, db, close, cb) {
function migrationFiles(files, callback, config, internals,
passedClass, db, close, cb) {
var file,
switched = false,
newConf;

var internals = {};
var _config = config;
if( config.config ) {
internals = config.internals;
config = config.config;
}

if(files.length === 1)
{
db.close = close;
}

file = files.pop();
log.info( 'Enter scope "' + ((file !== '') ? file : '/') + '"' );
console.log(internals)

if(file !== '')
{
Expand Down
5 changes: 1 addition & 4 deletions lib/migrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,9 @@ Migrator = function(driver, migrationsDir, empty, intern) {
this.migrationsDir = migrationsDir;
this.internals = intern;

if(intern.linked === true) {
if(intern.linked === false) {

this.seedLink = new SeedLink(driver, intern);
}
else {

intern.linked = true;
}

Expand Down
7 changes: 2 additions & 5 deletions lib/seeder.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,10 @@ Seeder = function (driver, seedsDir, versionControlled, intern) {
this.seedDir = seedsDir;
this.isVC = versionControlled;

if(intern.linked === true) {

this.migrationLink = new MigrationLink(driver, intern);
}
else {
if(intern.linked === false) {

intern.linked = true;
this.migrationLink = new MigrationLink(driver, intern);
}

internals = intern;
Expand Down

0 comments on commit c0fb2ae

Please sign in to comment.