X-Git-Url: http://repos.xcallymotion.com/?a=blobdiff_plain;f=server%2Fmigrations%2F2.5.7.js;h=93422ad1757161f9567c27e4acde86a7997bec2d;hb=54b4ff96e83f911255a158fd7e32a0e84ec4b7d0;hp=1bcbecd99faa7aa046e13b014763343cfe283d64;hpb=b9d8fb89c04e2712a06e4d6666f975c8e677d46a;p=motion2.git diff --git a/server/migrations/2.5.7.js b/server/migrations/2.5.7.js index 1bcbecd..93422ad 100644 --- a/server/migrations/2.5.7.js +++ b/server/migrations/2.5.7.js @@ -5,115 +5,115 @@ var util = require('util'); var logger = require('../config/logger')('migration'); -var Sequence = function () { }; +var Sequence = function() {}; -Sequence.prototype.enqueue = function (fn) { +Sequence.prototype.enqueue = function(fn) { this.tail = this.tail ? this.tail.finally(fn) : fn(); }; -var Migration = function (queryInterface) { +var Migration = function(queryInterface) { this.queryInterface = queryInterface; this.sequence = new Sequence(); }; -Migration.prototype.changeColumn = function (table, column, type) { +Migration.prototype.changeColumn = function(table, column, type) { var _this = this; - this.sequence.enqueue(function () { + this.sequence.enqueue(function() { return _this.queryInterface .changeColumn(table, column, type) - .then(function () { + .then(function() { logger.info('Changed column %s in table %s', column, table); }) - .catch(function (err) { + .catch(function(err) { logger.info(JSON.stringify(err)); }); }); }; -Migration.prototype.addColumn = function (table, column, type) { +Migration.prototype.addColumn = function(table, column, type) { var _this = this; - this.sequence.enqueue(function () { + this.sequence.enqueue(function() { return _this.queryInterface .addColumn(table, column, type) - .then(function () { + .then(function() { logger.info('Added column %s to %s', column, table); }) - .catch(function (err) { + .catch(function(err) { logger.info(JSON.stringify(err)); }); }); }; -Migration.prototype.dropTable = function (table) { +Migration.prototype.dropTable = function(table) { var _this = this; - this.sequence.enqueue(function () { + this.sequence.enqueue(function() { return _this.queryInterface .dropTable(table, { force: true }) - .then(function () { + .then(function() { logger.info('table dropped %s', table); }) - .catch(function (err) { + .catch(function(err) { logger.info(JSON.stringify(err)); }); }); }; -Migration.prototype.addIndex = function (table, column, options) { +Migration.prototype.addIndex = function(table, column, options) { var _this = this; - this.sequence.enqueue(function () { + this.sequence.enqueue(function() { return _this.queryInterface .addIndex(table, column, { indexName: options.indexName, indicesType: options.indicesType }) - .then(function () { + .then(function() { logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType); }) - .catch(function (err) { + .catch(function(err) { logger.info(JSON.stringify(err)); }); }); }; -Migration.prototype.removeIndex = function (table, indexName) { +Migration.prototype.removeIndex = function(table, indexName) { var _this = this; - this.sequence.enqueue(function () { + this.sequence.enqueue(function() { return _this.queryInterface .removeIndex(table, indexName) - .then(function () { + .then(function() { logger.info('removeIndex %s %s', table, indexName); }) - .catch(function (err) { + .catch(function(err) { logger.info(JSON.stringify(err)); }); }); }; -Migration.prototype.query = function (sql) { +Migration.prototype.query = function(sql) { var _this = this; - this.sequence.enqueue(function () { + this.sequence.enqueue(function() { return _this.queryInterface.sequelize .query(sql) - .then(function () { + .then(function() { logger.info('query %s', sql); }) - .catch(function (err) { + .catch(function(err) { logger.info(JSON.stringify(err)); }); }); }; -Migration.prototype.removeColumn = function (table, column) { +Migration.prototype.removeColumn = function(table, column) { var _this = this; - this.sequence.enqueue(function () { + this.sequence.enqueue(function() { return _this.queryInterface .removeColumn(table, column) - .then(function () { + .then(function() { logger.info('Removed column %s from %s', column, table); }) - .catch(function (err) { + .catch(function(err) { logger.info( util.inspect(err, { showHidden: false, @@ -124,15 +124,15 @@ Migration.prototype.removeColumn = function (table, column) { }); }; -Migration.prototype.renameColumn = function (table, oldColumn, newColumn) { +Migration.prototype.renameColumn = function(table, oldColumn, newColumn) { var _this = this; - this.sequence.enqueue(function () { + this.sequence.enqueue(function() { return _this.queryInterface .renameColumn(table, oldColumn, newColumn) - .then(function () { + .then(function() { logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table); }) - .catch(function (err) { + .catch(function(err) { logger.info( util.inspect(err, { showHidden: false, @@ -143,15 +143,15 @@ Migration.prototype.renameColumn = function (table, oldColumn, newColumn) { }); }; -Migration.prototype.final = function (resolve) { - this.sequence.enqueue(function () { +Migration.prototype.final = function(resolve) { + this.sequence.enqueue(function() { return resolve(); }); }; module.exports = { - up: function (queryInterface, Sequelize) { - return new BPromise(function (resolve) { + up: function(queryInterface, Sequelize) { + return new BPromise(function(resolve) { var migration = new Migration(queryInterface); @@ -203,7 +203,7 @@ module.exports = { }); }, - down: function (queryInterface, Sequelize) { + down: function(queryInterface, Sequelize) { // var migration = new Migration(queryInterface); } }; \ No newline at end of file