diff --git a/backend/migrations/20241023113359-fixTypoInJobGroupName.js b/backend/migrations/20241023113359-fixTypoInJobGroupName.js new file mode 100644 index 0000000000..9e046c6f80 --- /dev/null +++ b/backend/migrations/20241023113359-fixTypoInJobGroupName.js @@ -0,0 +1,34 @@ +'use strict'; + +const table = { + tableName: 'Job', + schema: 'cqc', +}; + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + return queryInterface.sequelize.transaction(async (transaction) => { + queryInterface + .removeColumn(table, 'JobRoleGroup', transaction) + .then(async () => { + await queryInterface.sequelize.query('DROP TYPE IF EXISTS cqc."enum_Job_JobRoleGroup";', transaction); + }) + .then(async () => { + await queryInterface.addColumn(table, 'JobRoleGroup', { + type: Sequelize.DataTypes.ENUM, + values: [ + 'Care providing roles', + 'Professional and related roles', + 'Managerial and supervisory roles', + 'IT, digital and data roles', + 'Other roles', + ], + transaction, + }); + }); + }); + }, + + async down(queryInterface) {}, +}; diff --git a/backend/migrations/20241023115350-reassignJobRoleGroupsWithChange.js b/backend/migrations/20241023115350-reassignJobRoleGroupsWithChange.js new file mode 100644 index 0000000000..df0256f169 --- /dev/null +++ b/backend/migrations/20241023115350-reassignJobRoleGroupsWithChange.js @@ -0,0 +1,49 @@ +'use strict'; +const models = require('../server/models/index'); + +const jobRoleGroups = { + ['Care providing roles']: [25, 10, 11, 20, 39], + ['Professional and related roles']: [27, 18, 23, 4, 19, 17, 16], + ['Managerial and supervisory roles']: [26, 15, 13, 22, 28, 14, 30, 32], + ['IT, digital and data roles']: [33, 34, 35, 36, 37, 38], + ['Other roles']: [12, 3, 2, 5, 21, 1, 24, 7, 8, 6, 31], +}; + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface, Sequelize) { + return queryInterface.sequelize.transaction(async (transaction) => { + for (let key of Object.keys(jobRoleGroups)) { + await models.job.update( + { + jobRoleGroup: key, + }, + { + where: { + id: { [Sequelize.Op.in]: jobRoleGroups[key] }, + }, + }, + { transaction }, + ); + } + }); + }, + + async down(queryInterface, Sequelize) { + return queryInterface.sequelize.transaction(async (transaction) => { + await models.job.update( + { + jobRoleGroup: null, + }, + { + where: { + jobRoleGroup: { + [Sequelize.Op.ne]: null, + }, + }, + }, + { transaction }, + ); + }); + }, +}; diff --git a/backend/server/models/job.js b/backend/server/models/job.js index d8c9e3bb11..c2750615d7 100644 --- a/backend/server/models/job.js +++ b/backend/server/models/job.js @@ -1,6 +1,6 @@ /* jshint indent: 2 */ -const { timeStamp } = require("console"); +const { timeStamp } = require('console'); module.exports = function (sequelize, DataTypes) { const Job = sequelize.define( @@ -34,11 +34,11 @@ module.exports = function (sequelize, DataTypes) { 'Care providing roles', 'Professional and related roles', 'Managerial and supervisory roles', - 'IT, digital and date roles', + 'IT, digital and data roles', 'Other roles', ], field: 'JobRoleGroup', - } + }, }, { tableName: '"Job"', diff --git a/frontend/src/app/features/workers/main-job-role/main-job-role.component.ts b/frontend/src/app/features/workers/main-job-role/main-job-role.component.ts index 7d42d0d0f7..0663f2fabc 100644 --- a/frontend/src/app/features/workers/main-job-role/main-job-role.component.ts +++ b/frontend/src/app/features/workers/main-job-role/main-job-role.component.ts @@ -30,7 +30,7 @@ export class MainJobRoleComponent extends QuestionComponent implements OnInit, O 'Care providing roles': 'care worker, community support, support worker', 'Professional and related roles': 'occupational therapist, registered nurse, nursing assistant', 'Managerial and supervisory roles': 'registered manager, supervisor, team leader', - 'IT, digital and date roles': 'data analyst, IT and digital support, IT manager', + 'IT, digital and data roles': 'data analyst, IT and digital support, IT manager', 'Other roles': 'admin, care co-ordinator, learning and development', };