var logger = require('../config/logger')('migration');
var Migration = function(queryInterface) {
- this.queryInterface = queryInterface;
+ this.queryInterface = queryInterface;
};
Migration.prototype.addColumn = function(table, column, type) {
- 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));
- });
+ 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.removeColumn = function(table, column) {
- return this.queryInterface
- .removeColumn(table, column)
- .then(function(res) {
- logger.info('Removed column %s from %s', column, table);
- })
- .catch(function(err) {
- logger.info(JSON.stringify(err));
- });
+ return this.queryInterface
+ .removeColumn(table, column)
+ .then(function(res) {
+ logger.info('Removed column %s from %s', column, table);
+ })
+ .catch(function(err) {
+ logger.info(JSON.stringify(err));
+ });
};
Migration.prototype.renameColumn = function(table, oldColumn, newColumn) {
- return this.queryInterface
- .renameColumn(table, oldColumn, newColumn)
- .then(function(res) {
- logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table);
- })
- .catch(function(err) {
- logger.info(JSON.stringify(err));
- });
+ return this.queryInterface
+ .renameColumn(table, oldColumn, newColumn)
+ .then(function(res) {
+ logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table);
+ })
+ .catch(function(err) {
+ logger.info(JSON.stringify(err));
+ });
};
Migration.prototype.dropTable = function(table) {
- return this.queryInterface
- .dropTable(table)
- .then(function(res) {
- logger.info('table dropped %s', table);
- })
- .catch(function(err) {
- logger.info(JSON.stringify(err));
- });
+ return this.queryInterface
+ .dropTable(table)
+ .then(function(res) {
+ logger.info('table dropped %s', table);
+ })
+ .catch(function(err) {
+ logger.info(JSON.stringify(err));
+ });
};
module.exports = {
- up: function(queryInterface, Sequelize) {
- var migration = new Migration(queryInterface);
-
- migration.addColumn('int_salesforce_accounts', 'type', {
- type: Sequelize.ENUM('integrationTab', 'newTab'),
- defaultValue: 'integrationTab'
- });
-
- migration.addColumn('int_zendesk_accounts', 'type', {
- type: Sequelize.ENUM('integrationTab', 'newTab'),
- defaultValue: 'integrationTab'
- });
-
- migration.dropTable('user_has_openchannel_rooms', {
- force: true
- });
-
- migration.dropTable('openchannel_messages', {
- force: true
- });
-
- migration.dropTable('openchannel_rooms', {
- force: true
- });
-
- migration.dropTable('openchannel_applications', {
- force: true
- });
-
- migration.dropTable('openchannel_accounts', {
- force: true
- });
- },
-
- down: function(queryInterface, Sequelize) {
- var migration = new Migration(queryInterface);
- migration.removeColumn('int_salesforce_accounts', 'type');
- migration.removeColumn('int_zendesk_accounts', 'type');
- }
-};
\ No newline at end of file
+ up: function(queryInterface, Sequelize) {
+ var migration = new Migration(queryInterface);
+
+ migration.addColumn('int_salesforce_accounts', 'type', {
+ type: Sequelize.ENUM('integrationTab', 'newTab'),
+ defaultValue: 'integrationTab'
+ });
+
+ migration.addColumn('int_zendesk_accounts', 'type', {
+ type: Sequelize.ENUM('integrationTab', 'newTab'),
+ defaultValue: 'integrationTab'
+ });
+
+ migration.dropTable('user_has_openchannel_rooms', {
+ force: true
+ });
+
+ migration.dropTable('openchannel_messages', {
+ force: true
+ });
+
+ migration.dropTable('openchannel_rooms', {
+ force: true
+ });
+
+ migration.dropTable('openchannel_applications', {
+ force: true
+ });
+
+ migration.dropTable('openchannel_accounts', {
+ force: true
+ });
+ },
+
+ down: function(queryInterface, Sequelize) {
+ var migration = new Migration(queryInterface);
+ migration.removeColumn('int_salesforce_accounts', 'type');
+ migration.removeColumn('int_zendesk_accounts', 'type');
+ }
+};