Skip to content

Commit 8667077

Browse files
add migration scripts
1 parent 7d5349d commit 8667077

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const config = require('config')
2+
3+
/*
4+
* Add rcrm_status, rcrm_reason to the Job model.
5+
type: Sequelize.STRING(255),
6+
defaultValue: null,
7+
allowNull: true
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 }, 'rcrm_status',
15+
{ type: Sequelize.STRING(255), allowNull: true, defaultValue: null },
16+
{ transaction })
17+
await queryInterface.addColumn({ tableName: 'jobs', schema: config.DB_SCHEMA_NAME }, 'rcrm_reason',
18+
{ type: Sequelize.STRING(255), allowNull: true, defaultValue: null },
19+
{ transaction })
20+
await transaction.commit()
21+
} catch (err) {
22+
await transaction.rollback()
23+
throw err
24+
}
25+
},
26+
down: async (queryInterface, Sequelize) => {
27+
const transaction = await queryInterface.sequelize.transaction()
28+
try {
29+
await queryInterface.removeColumn({ tableName: 'jobs', schema: config.DB_SCHEMA_NAME }, 'rcrm_status', { transaction })
30+
await queryInterface.removeColumn({ tableName: 'jobs', schema: config.DB_SCHEMA_NAME }, 'rcrm_reason', { transaction })
31+
await transaction.commit()
32+
} catch (err) {
33+
await transaction.rollback()
34+
throw err
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)