From ec94c8e93d74ca4ea1de51420882ef3a38befad8 Mon Sep 17 00:00:00 2001 From: Anthony Benites <104385099+ec2sw@users.noreply.github.com> Date: Thu, 21 Jul 2022 17:37:19 -0400 Subject: [PATCH] feat: add optional methodology2 field to project --- ...-optional-methodology2-field-to-project.js | 22 +++++++++++++++++++ src/database/migrations/index.js | 7 +++++- src/models/projects/projects.model.js | 1 + src/models/projects/projects.modeltypes.cjs | 3 +++ src/validations/projects.validations.js | 1 + 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/database/migrations/20220721212845-add-optional-methodology2-field-to-project.js diff --git a/src/database/migrations/20220721212845-add-optional-methodology2-field-to-project.js b/src/database/migrations/20220721212845-add-optional-methodology2-field-to-project.js new file mode 100644 index 00000000..c7acf952 --- /dev/null +++ b/src/database/migrations/20220721212845-add-optional-methodology2-field-to-project.js @@ -0,0 +1,22 @@ +'use strict'; + +export default { + async up(queryInterface, Sequelize) { + await Promise.all( + ['projects'].map((table) => { + queryInterface.addColumn(table, 'methodology2', { + type: Sequelize.STRING, + allowNull: true, + }); + }), + ); + }, + + async down(queryInterface) { + await Promise.all( + ['projects'].map((table) => { + queryInterface.removeColumn(table, 'methodology2'); + }), + ); + }, +}; diff --git a/src/database/migrations/index.js b/src/database/migrations/index.js index efa49732..7a42a527 100644 --- a/src/database/migrations/index.js +++ b/src/database/migrations/index.js @@ -23,6 +23,7 @@ import AddSerialNumberFields from './20220504180739-add-serial-number-fields'; import AddDescriptionFieldToProjects from './20220509125335-add-description-field-to-projects'; import RepopulateVirtualTables from './20220515223227-re-populate-virtual-tables'; import AddAuthorColumnToAuditTable from './20220708210357-adding-author-column-to-audit-table'; +import AddOptionalMethodology2FieldToProject from './20220721212845-add-optional-methodology2-field-to-project'; export const migrations = [ { @@ -128,5 +129,9 @@ export const migrations = [ { migration: AddAuthorColumnToAuditTable, name: '20220708210357-adding-author-column-to-audit-table', - } + }, + { + migration: AddOptionalMethodology2FieldToProject, + name: '20220721212845-add-optional-methodology2-field-to-project', + }, ]; diff --git a/src/models/projects/projects.model.js b/src/models/projects/projects.model.js index d1b4d080..bc54eea2 100644 --- a/src/models/projects/projects.model.js +++ b/src/models/projects/projects.model.js @@ -203,6 +203,7 @@ class Project extends Model { projectStatus, unitMetric, methodology, + methodology2, methodologyVersion, validationApproach, projectTag, diff --git a/src/models/projects/projects.modeltypes.cjs b/src/models/projects/projects.modeltypes.cjs index 12682508..99453971 100644 --- a/src/models/projects/projects.modeltypes.cjs +++ b/src/models/projects/projects.modeltypes.cjs @@ -80,6 +80,9 @@ module.exports = { type: Sequelize.STRING, required: true, }, + methodology2: { + type: Sequelize.STRING, + }, validationBody: Sequelize.STRING, validationDate: Sequelize.DATE, timeStaged: { diff --git a/src/validations/projects.validations.js b/src/validations/projects.validations.js index cfc43568..97db3a84 100644 --- a/src/validations/projects.validations.js +++ b/src/validations/projects.validations.js @@ -39,6 +39,7 @@ export const baseSchema = { projectStatusDate: Joi.date().required(), unitMetric: Joi.string().custom(pickListValidation('unitMetric')).required(), methodology: Joi.string().required(), + methodology2: Joi.string().optional(), validationBody: Joi.string() .custom(pickListValidation('validationBody')) .optional(),