Built motion from commit 3e059bc2.|2.5.32
[motion2.git] / server / migrations / 2.0.36.js
index 6d897ef..efdd6e4 100644 (file)
@@ -8,133 +8,133 @@ var util = require('util');
 var Sequence = function() {};
 
 Sequence.prototype.enqueue = function(fn) {
-    this.tail = this.tail ? this.tail.finally(fn) : fn();
+  this.tail = this.tail ? this.tail.finally(fn) : fn();
 };
 
 var Migration = function(queryInterface) {
-    this.queryInterface = queryInterface;
-    this.sequence = new Sequence();
+  this.queryInterface = queryInterface;
+  this.sequence = new Sequence();
 };
 
 Migration.prototype.changeColumn = function(table, column, type) {
-    var _this = this;
-    this.sequence.enqueue(function() {
-        return _this.queryInterface
-            .changeColumn(table, column, type)
-            .then(function(res) {
-                logger.info('Changed column %s in table %s', column, table);
-            })
-            .catch(function(err) {
-                logger.info(JSON.stringify(err));
-            });
-    });
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return _this.queryInterface
+      .changeColumn(table, column, type)
+      .then(function(res) {
+        logger.info('Changed column %s in table %s', column, table);
+      })
+      .catch(function(err) {
+        logger.info(JSON.stringify(err));
+      });
+  });
 };
 
 Migration.prototype.addColumn = function(table, column, type) {
-    var _this = this;
-    this.sequence.enqueue(function() {
-        return _this.queryInterface
-            .addColumn(table, column, type)
-            .then(function(res) {
-                logger.info('Added column %s to %s', column, table);
-            })
-            .catch(function(err) {
-                logger.info(JSON.stringify(err));
-            });
-    });
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return _this.queryInterface
+      .addColumn(table, column, type)
+      .then(function(res) {
+        logger.info('Added column %s to %s', column, table);
+      })
+      .catch(function(err) {
+        logger.info(JSON.stringify(err));
+      });
+  });
 };
 
 Migration.prototype.dropTable = function(table) {
-    var _this = this;
-    this.sequence.enqueue(function() {
-        return _this.queryInterface
-            .dropTable(table, {
-                force: true
-            })
-            .then(function(res) {
-                logger.info('table dropped %s', table);
-            })
-            .catch(function(err) {
-                logger.info(JSON.stringify(err));
-            });
-    });
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return _this.queryInterface
+      .dropTable(table, {
+        force: true
+      })
+      .then(function(res) {
+        logger.info('table dropped %s', table);
+      })
+      .catch(function(err) {
+        logger.info(JSON.stringify(err));
+      });
+  });
 };
 
 Migration.prototype.addIndex = function(table, column, indexName) {
-    var _this = this;
-    this.sequence.enqueue(function() {
-        return _this.queryInterface.addIndex(table, column, {
-                indexName: indexName
-            })
-            .then(function(res) {
-                logger.info('addIndex %s %s %s', table, column.join(','), indexName);
-            })
-            .catch(function(err) {
-                logger.info(JSON.stringify(err));
-            });
-    });
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return _this.queryInterface.addIndex(table, column, {
+        indexName: indexName
+      })
+      .then(function(res) {
+        logger.info('addIndex %s %s %s', table, column.join(','), indexName);
+      })
+      .catch(function(err) {
+        logger.info(JSON.stringify(err));
+      });
+  });
 };
 
 Migration.prototype.query = function(sql) {
-    var _this = this;
-    this.sequence.enqueue(function() {
-        return _this.queryInterface.sequelize.query(sql)
-            .then(function(res) {
-                logger.info('query %s', sql);
-            })
-            .catch(function(err) {
-                logger.info(JSON.stringify(err));
-            });
-    });
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return _this.queryInterface.sequelize.query(sql)
+      .then(function(res) {
+        logger.info('query %s', sql);
+      })
+      .catch(function(err) {
+        logger.info(JSON.stringify(err));
+      });
+  });
 };
 
 Migration.prototype.removeColumn = function(table, column) {
-    var _this = this;
-    this.sequence.enqueue(function() {
-        return _this.queryInterface.removeColumn(table, column)
-            .then(function(res) {
-                logger.info('Removed column %s from %s', column, table);
-            })
-            .catch(function(err) {
-                logger.info(util.inspect(err, {
-                    showHidden: false,
-                    depth: null
-                }));
-            });
-    });
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return _this.queryInterface.removeColumn(table, column)
+      .then(function(res) {
+        logger.info('Removed column %s from %s', column, table);
+      })
+      .catch(function(err) {
+        logger.info(util.inspect(err, {
+          showHidden: false,
+          depth: null
+        }));
+      });
+  });
 };
 
 Migration.prototype.final = function(resolve) {
-    var _this = this;
-    this.sequence.enqueue(function() {
-        return resolve();
-    });
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return resolve();
+  });
 };
 
 module.exports = {
-    up: function(queryInterface, Sequelize) {
-        return new BPromise(function(resolve, reject) {
-            var migration = new Migration(queryInterface);
-
-            //START OPENCHANNEL MESSAGES
-            migration.addColumn('openchannel_messages', 'AttachmentId', {
-              type: Sequelize.INTEGER
-            });
-            migration.query('ALTER TABLE `openchannel_messages` \
+  up: function(queryInterface, Sequelize) {
+    return new BPromise(function(resolve, reject) {
+      var migration = new Migration(queryInterface);
+
+      //START OPENCHANNEL MESSAGES
+      migration.addColumn('openchannel_messages', 'AttachmentId', {
+        type: Sequelize.INTEGER
+      });
+      migration.query('ALTER TABLE `openchannel_messages` \
               ADD CONSTRAINT `openchannel_messages_ibfk_5` \
               FOREIGN KEY (`AttachmentId`) \
               REFERENCES attachments(`id`) \
               ON UPDATE CASCADE \
               ON DELETE SET NULL');
-            //END OPENCHANNEL MESSAGES
+      //END OPENCHANNEL MESSAGES
 
-            // START FINAL
-            migration.final(resolve);
-            // END FINAL
-        });
-    },
+      // START FINAL
+      migration.final(resolve);
+      // END FINAL
+    });
+  },
 
-    down: function(queryInterface, Sequelize) {
-        var migration = new Migration(queryInterface);
-    }
-};
+  down: function(queryInterface, Sequelize) {
+    var migration = new Migration(queryInterface);
+  }
+};
\ No newline at end of file