Skip to content

Commit

Permalink
fix(walker): rename interface to Interface
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Gurtzick <[email protected]>
  • Loading branch information
wzrdtales committed Apr 10, 2018
1 parent 89c6ec3 commit 6234d42
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions lib/walker.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
'use strict';

const dbmUtil = require('db-migrate-shared').util;
const log = require('db-migrate-shared').log;
const Promise = require('bluebird');
const File = require('./file.js');

// Not sure what will happen to this yet
function SeedLink(driver, internals) {
function SeedLink (driver, internals) {
this.seeder = require('./seeder.js')(
driver,
internals.argv['vcseeder-dir'],
Expand All @@ -15,8 +17,8 @@ function SeedLink(driver, internals) {
this.links = [];
}

const Walker = function(driver, directory, interface, empty, intern) {
this.driver = dbmUtil.reduceToInterface(driver, interface);
const Walker = function (driver, directory, Interface, empty, intern) {
this.driver = dbmUtil.reduceToInterface(driver, Interface);
this._driver = driver;
this.directory = directory;
this.internals = intern;
Expand All @@ -29,12 +31,12 @@ const Walker = function(driver, directory, interface, empty, intern) {
};

Walker.prototype = {
createMigrationsTable: function(callback) {
createMigrationsTable: function (callback) {
this._driver.createMigrationsTable(callback);
},

writeMigrationRecord: function(migration, callback) {
function onComplete(err) {
writeMigrationRecord: function (migration, callback) {
function onComplete (err) {
if (err) {
log.error(this.prefix + migration.name, err);
} else {
Expand All @@ -48,8 +50,8 @@ Walker.prototype = {
);
},

deleteMigrationRecord: function(migration, callback) {
function onComplete(err) {
deleteMigrationRecord: function (migration, callback) {
function onComplete (err) {
if (err) {
log.error(this.prefix + migration.name, err);
} else {
Expand All @@ -59,7 +61,7 @@ Walker.prototype = {
}
this._driver.deleteMigration(
this.internals.matching + '/' + migration.name,
function(err) {
function (err) {
if (!this.internals.matching) {
this._driver.deleteMigration(migration.name, onComplete);
} else {
Expand All @@ -69,10 +71,10 @@ Walker.prototype = {
);
},

sync: function(options, callback) {
sync: function (options, callback) {
return File.loadFromDatabase(this.directory, this._driver, this.internals)
.then(completedFiles => {
const mode = dbmUtil.syncMode(completedFiles, funcOrOpts.destination);
const mode = dbmUtil.syncMode(completedFiles, options.destination);
if (mode === 1) {
log.info(this.prefix + 'Syncing upwards.');
return this.up(options);
Expand All @@ -84,7 +86,7 @@ Walker.prototype = {
.nodeify(callback);
},

up: function({ partialName, count }, callback) {
up: function ({ partialName, count }, callback) {
return Promise.all([
File.loadFromFilesystem(this.directory, this.internals),
File.loadFromDatabase(this.directory, this._driver, this.internals)
Expand All @@ -106,12 +108,12 @@ Walker.prototype = {
.each(file => {
log.verbose(this.prefix + 'preparing to run up:', file.name);
const version = file.get()._meta.version || 1;
require('./executors/versioned/v' + version).up(this.driver, file);
require(`./executors/versioned/v${version}`).up(this.driver, file);
})
.nodeify(callback);
},

down: function({ partialName, count }, callback) {
down: function ({ partialName, count }, callback) {
return File.loadFromDatabase(this.directory, this._driver, this.internals)
.then(completedFiles => {
const toRun = dbmUtil.filterDown(completedFiles, partialName, count);
Expand All @@ -125,7 +127,7 @@ Walker.prototype = {
.each(file => {
log.verbose(this.prefix + 'preparing to run down:', file.name);
const version = file.get()._meta.version || 1;
require('./executors/versioned/v' + version).down(this.driver, file);
require(`./executors/versioned/v${version}`).down(this.driver, file);
})
.nodeify(callback);
}
Expand Down

0 comments on commit 6234d42

Please sign in to comment.