Built motion from commit (unavailable).|2.5.23
[motion2.git] / server / migrations / 2.5.11.js
index 7a702f1..57923db 100644 (file)
-'use strict';\r
-\r
-var BPromise = require('bluebird');\r
-var util = require('util');\r
-\r
-var logger = require('../config/logger')('migration');\r
-\r
-var Sequence = function () {};\r
-\r
-Sequence.prototype.enqueue = function (fn) {\r
-  this.tail = this.tail ? this.tail.finally(fn) : fn();\r
-};\r
-\r
-var Migration = function (queryInterface) {\r
-  this.queryInterface = queryInterface;\r
-  this.sequence = new Sequence();\r
-};\r
-\r
-Migration.prototype.changeColumn = function (table, column, type) {\r
-  var _this = this;\r
-  this.sequence.enqueue(function () {\r
-    return _this.queryInterface\r
-      .changeColumn(table, column, type)\r
-      .then(function () {\r
-        logger.info('Changed column %s in table %s', column, table);\r
-      })\r
-      .catch(function (err) {\r
-        logger.info(JSON.stringify(err));\r
-      });\r
-  });\r
-};\r
-\r
-Migration.prototype.addColumn = function (table, column, type) {\r
-  var _this = this;\r
-  this.sequence.enqueue(function () {\r
-    return _this.queryInterface\r
-      .addColumn(table, column, type)\r
-      .then(function () {\r
-        logger.info('Added column %s to %s', column, table);\r
-      })\r
-      .catch(function (err) {\r
-        logger.info(JSON.stringify(err));\r
-      });\r
-  });\r
-};\r
-\r
-Migration.prototype.dropTable = function (table) {\r
-  var _this = this;\r
-  this.sequence.enqueue(function () {\r
-    return _this.queryInterface\r
-      .dropTable(table, {\r
-        force: true\r
-      })\r
-      .then(function () {\r
-        logger.info('table dropped %s', table);\r
-      })\r
-      .catch(function (err) {\r
-        logger.info(JSON.stringify(err));\r
-      });\r
-  });\r
-};\r
-\r
-Migration.prototype.addIndex = function (table, column, options) {\r
-  var _this = this;\r
-  this.sequence.enqueue(function () {\r
-    return _this.queryInterface\r
-      .addIndex(table, column, {\r
-        indexName: options.indexName,\r
-        indicesType: options.indicesType\r
-      })\r
-      .then(function () {\r
-        logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType);\r
-      })\r
-      .catch(function (err) {\r
-        logger.info(JSON.stringify(err));\r
-      });\r
-  });\r
-};\r
-\r
-Migration.prototype.removeIndex = function (table, indexName) {\r
-  var _this = this;\r
-  this.sequence.enqueue(function () {\r
-    return _this.queryInterface\r
-      .removeIndex(table, indexName)\r
-      .then(function () {\r
-        logger.info('removeIndex %s %s', table, indexName);\r
-      })\r
-      .catch(function (err) {\r
-        logger.info(JSON.stringify(err));\r
-      });\r
-  });\r
-};\r
-\r
-Migration.prototype.query = function (sql) {\r
-  var _this = this;\r
-  this.sequence.enqueue(function () {\r
-    return _this.queryInterface.sequelize\r
-      .query(sql)\r
-      .then(function () {\r
-        logger.info('query %s', sql);\r
-      })\r
-      .catch(function (err) {\r
-        logger.info(JSON.stringify(err));\r
-      });\r
-  });\r
-};\r
-\r
-Migration.prototype.removeColumn = function (table, column) {\r
-  var _this = this;\r
-  this.sequence.enqueue(function () {\r
-    return _this.queryInterface\r
-      .removeColumn(table, column)\r
-      .then(function () {\r
-        logger.info('Removed column %s from %s', column, table);\r
-      })\r
-      .catch(function (err) {\r
-        logger.info(\r
-          util.inspect(err, {\r
-            showHidden: false,\r
-            depth: null\r
-          })\r
-        );\r
-      });\r
-  });\r
-};\r
-\r
-Migration.prototype.renameColumn = function (table, oldColumn, newColumn) {\r
-  var _this = this;\r
-  this.sequence.enqueue(function () {\r
-    return _this.queryInterface\r
-      .renameColumn(table, oldColumn, newColumn)\r
-      .then(function () {\r
-        logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table);\r
-      })\r
-      .catch(function (err) {\r
-        logger.info(\r
-          util.inspect(err, {\r
-            showHidden: false,\r
-            depth: null\r
-          })\r
-        );\r
-      });\r
-  });\r
-};\r
-\r
-Migration.prototype.final = function (resolve) {\r
-  this.sequence.enqueue(function () {\r
-    return resolve();\r
-  });\r
-};\r
-\r
-module.exports = {\r
-  up: function (queryInterface, Sequelize) {\r
-    return new BPromise(function (resolve) {\r
-\r
-      var migration = new Migration(queryInterface);\r
-\r
-      // START FINAL\r
-      migration.final(resolve);\r
-      // END FINAL\r
-    });\r
-  },\r
-\r
-  down: function (queryInterface, Sequelize) {\r
-    // var migration = new Migration(queryInterface);\r
-  }\r
-};
\ No newline at end of file
+'use strict';
+
+var BPromise = require('bluebird');
+var util = require('util');
+
+var logger = require('../config/logger')('migration');
+
+var Sequence = function () {};
+
+Sequence.prototype.enqueue = function (fn) {
+  this.tail = this.tail ? this.tail.finally(fn) : fn();
+};
+
+var Migration = function (queryInterface) {
+  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 () {
+        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 () {
+        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 () {
+        logger.info('table dropped %s', table);
+      })
+      .catch(function (err) {
+        logger.info(JSON.stringify(err));
+      });
+  });
+};
+
+Migration.prototype.addIndex = function (table, column, options) {
+  var _this = this;
+  this.sequence.enqueue(function () {
+    return _this.queryInterface
+      .addIndex(table, column, {
+        indexName: options.indexName,
+        indicesType: options.indicesType
+      })
+      .then(function () {
+        logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType);
+      })
+      .catch(function (err) {
+        logger.info(JSON.stringify(err));
+      });
+  });
+};
+
+Migration.prototype.removeIndex = function (table, indexName) {
+  var _this = this;
+  this.sequence.enqueue(function () {
+    return _this.queryInterface
+      .removeIndex(table, indexName)
+      .then(function () {
+        logger.info('removeIndex %s %s', table, 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 () {
+        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 () {
+        logger.info('Removed column %s from %s', column, table);
+      })
+      .catch(function (err) {
+        logger.info(
+          util.inspect(err, {
+            showHidden: false,
+            depth: null
+          })
+        );
+      });
+  });
+};
+
+Migration.prototype.renameColumn = function (table, oldColumn, newColumn) {
+  var _this = this;
+  this.sequence.enqueue(function () {
+    return _this.queryInterface
+      .renameColumn(table, oldColumn, newColumn)
+      .then(function () {
+        logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table);
+      })
+      .catch(function (err) {
+        logger.info(
+          util.inspect(err, {
+            showHidden: false,
+            depth: null
+          })
+        );
+      });
+  });
+};
+
+Migration.prototype.final = function (resolve) {
+  this.sequence.enqueue(function () {
+    return resolve();
+  });
+};
+
+module.exports = {
+  up: function (queryInterface, Sequelize) {
+    return new BPromise(function (resolve) {
+
+      var migration = new Migration(queryInterface);
+
+      // START FINAL
+      migration.final(resolve);
+      // END FINAL
+    });
+  },
+
+  down: function (queryInterface, Sequelize) {
+    // var migration = new Migration(queryInterface);
+  }
+};