Skip to content

Commit

Permalink
feat: add optional methodology2 field to project
Browse files Browse the repository at this point in the history
  • Loading branch information
ec2sw committed Jul 22, 2022
1 parent ccca25f commit ec94c8e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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');
}),
);
},
};
7 changes: 6 additions & 1 deletion src/database/migrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down Expand Up @@ -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',
},
];
1 change: 1 addition & 0 deletions src/models/projects/projects.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class Project extends Model {
projectStatus,
unitMetric,
methodology,
methodology2,
methodologyVersion,
validationApproach,
projectTag,
Expand Down
3 changes: 3 additions & 0 deletions src/models/projects/projects.modeltypes.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ module.exports = {
type: Sequelize.STRING,
required: true,
},
methodology2: {
type: Sequelize.STRING,
},
validationBody: Sequelize.STRING,
validationDate: Sequelize.DATE,
timeStaged: {
Expand Down
1 change: 1 addition & 0 deletions src/validations/projects.validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit ec94c8e

Please sign in to comment.