Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / migrations / 2.0.24.js
1 'use strict';
2 var BPromise = require('bluebird');
3
4 var logger = require('../config/logger')('migration');
5
6 var Migration = function(queryInterface) {
7   this.queryInterface = queryInterface;
8 };
9
10 Migration.prototype.addColumn = function(table, column, type) {
11   return this.queryInterface
12     .addColumn(table, column, type)
13     .then(function(res) {
14       logger.info('Added column %s to %s', column, table);
15     })
16     .catch(function(err) {
17       logger.info(JSON.stringify(err));
18     });
19
20 };
21
22 Migration.prototype.removeColumn = function(table, column) {
23   return this.queryInterface
24     .removeColumn(table, column)
25     .then(function(res) {
26       logger.info('Removed column %s from %s', column, table);
27     })
28     .catch(function(err) {
29       logger.info(JSON.stringify(err));
30     });
31
32 };
33
34 Migration.prototype.renameColumn = function(table, oldColumn, newColumn) {
35   return this.queryInterface
36     .renameColumn(table, oldColumn, newColumn)
37     .then(function(res) {
38       logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table);
39     })
40     .catch(function(err) {
41       logger.info(JSON.stringify(err));
42     });
43 };
44
45 Migration.prototype.dropTable = function(table) {
46   return this.queryInterface
47     .dropTable(table)
48     .then(function(res) {
49       logger.info('table dropped %s', table);
50     })
51     .catch(function(err) {
52       logger.info(JSON.stringify(err));
53     });
54 };
55
56 module.exports = {
57
58   up: function(queryInterface, Sequelize) {
59     var migration = new Migration(queryInterface);
60
61     migration.dropTable('tools_schedules', {
62       force: true
63     });
64   },
65
66   down: function(queryInterface, Sequelize) {
67     var migration = new Migration(queryInterface);
68   }
69 };