Skip to content

Commit a870d63

Browse files
update job model to have flag
1 parent fb4a89e commit a870d63

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
}

src/bootstrap.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Joi.page = () => Joi.number().integer().min(1).default(1)
1313
Joi.perPage = () => Joi.number().integer().min(1).default(20)
1414
Joi.rateType = () => Joi.string().valid('hourly', 'daily', 'weekly', 'monthly', 'annual')
1515
Joi.jobStatus = () => Joi.string().valid('sourcing', 'in-review', 'assigned', 'closed', 'cancelled')
16+
Joi.jobTag = () => Joi.string().valid('new', 'dollor', 'hot')
1617
Joi.resourceBookingStatus = () => Joi.string().valid('placed', 'closed', 'cancelled')
1718
Joi.workload = () => Joi.string().valid('full-time', 'fractional')
1819
Joi.jobCandidateStatus = () => Joi.string().valid('open', 'placed', 'selected', 'client rejected - screening', 'client rejected - interview', 'rejected - other', 'cancelled', 'interview', 'topcoder-rejected', 'applied', 'rejected-pre-screen', 'skills-test', 'skills-test', 'phone-screen', 'job-closed', 'offered', 'withdrawn', 'withdrawn-prescreen')

src/models/Job.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,30 @@ module.exports = (sequelize) => {
140140
type: Sequelize.UUID
141141
})
142142
},
143+
showInHotList: {
144+
field: 'show_in_hot_list',
145+
type: Sequelize.BOOLEAN,
146+
allowNull: true,
147+
defaultValue: false
148+
},
149+
featured: {
150+
field: 'featured',
151+
type: Sequelize.BOOLEAN,
152+
allowNull: true,
153+
defaultValue: false
154+
},
155+
hotListExcerpt: {
156+
field: 'hot_list_excerpt',
157+
type: Sequelize.STRING(255),
158+
allowNull: true,
159+
defaultValue: ''
160+
},
161+
jobTag: {
162+
field: 'job_tag',
163+
type: Sequelize.STRING(30),
164+
allowNull: true,
165+
defaultValue: ''
166+
},
143167
createdBy: {
144168
field: 'created_by',
145169
type: Sequelize.UUID,

0 commit comments

Comments
 (0)