|
| 1 | +const config = require('config') |
| 2 | + |
| 3 | +/* |
| 4 | + * Add show_in_hot_list, featured, hot_list_excerpt and job_tag to the Job model. |
| 5 | +type: Sequelize.BOOLEAN, |
| 6 | + defaultValue: false, |
| 7 | + allowNull: false |
| 8 | + */ |
| 9 | + |
| 10 | +module.exports = { |
| 11 | + up: async (queryInterface, Sequelize) => { |
| 12 | + const transaction = await queryInterface.sequelize.transaction() |
| 13 | + try { |
| 14 | + await queryInterface.addColumn({ tableName: 'jobs', schema: config.DB_SCHEMA_NAME }, 'show_in_hot_list', |
| 15 | + { type: Sequelize.BOOLEAN, allowNull: true, defaultValue: false }, |
| 16 | + { transaction }) |
| 17 | + await queryInterface.addColumn({ tableName: 'jobs', schema: config.DB_SCHEMA_NAME }, 'featured', |
| 18 | + { type: Sequelize.BOOLEAN, allowNull: true, defaultValue: false }, |
| 19 | + { transaction }) |
| 20 | + await queryInterface.addColumn({ tableName: 'jobs', schema: config.DB_SCHEMA_NAME }, 'hot_list_excerpt', |
| 21 | + { type: Sequelize.STRING(255), allowNull: true, defaultValue: '' }, |
| 22 | + { transaction }) |
| 23 | + await queryInterface.addColumn({ tableName: 'jobs', schema: config.DB_SCHEMA_NAME }, 'job_tag', |
| 24 | + { type: Sequelize.STRING(30), allowNull: true, defaultValue: '' }, |
| 25 | + { transaction }) |
| 26 | + await transaction.commit() |
| 27 | + } catch (err) { |
| 28 | + await transaction.rollback() |
| 29 | + throw err |
| 30 | + } |
| 31 | + }, |
| 32 | + down: async (queryInterface, Sequelize) => { |
| 33 | + const transaction = await queryInterface.sequelize.transaction() |
| 34 | + try { |
| 35 | + await queryInterface.removeColumn({ tableName: 'jobs', schema: config.DB_SCHEMA_NAME }, 'show_in_hot_list', { transaction }) |
| 36 | + await queryInterface.removeColumn({ tableName: 'jobs', schema: config.DB_SCHEMA_NAME }, 'featured', { transaction }) |
| 37 | + await queryInterface.removeColumn({ tableName: 'jobs', schema: config.DB_SCHEMA_NAME }, 'hot_list_excerpt', { transaction }) |
| 38 | + await queryInterface.removeColumn({ tableName: 'jobs', schema: config.DB_SCHEMA_NAME }, 'job_tag', { transaction }) |
| 39 | + await transaction.commit() |
| 40 | + } catch (err) { |
| 41 | + await transaction.rollback() |
| 42 | + throw err |
| 43 | + } |
| 44 | + } |
| 45 | +} |
0 commit comments