Skip to content

Commit cb0f4f6

Browse files
committed
feat: update "project.terms" type to string
ref issue #614
1 parent a2ffa2c commit cb0f4f6

File tree

8 files changed

+18
-13
lines changed

8 files changed

+18
-13
lines changed

docs/swagger.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4939,8 +4939,7 @@ definitions:
49394939
terms:
49404940
type: array
49414941
items:
4942-
type: number
4943-
format: integer
4942+
type: string
49444943
external:
49454944
type: object
49464945
description: 'READ-ONLY, OPTIONAL. Refernce to external task/issue.'
@@ -5070,8 +5069,7 @@ definitions:
50705069
terms:
50715070
type: array
50725071
items:
5073-
type: number
5074-
format: integer
5072+
type: string
50755073
name:
50765074
type: string
50775075
description: project name
@@ -5254,7 +5252,7 @@ definitions:
52545252
type:
52555253
type: string
52565254
description: The attachment type, one of 'link' or 'file'
5257-
enum:
5255+
enum:
52585256
- link
52595257
- file
52605258
tags:
@@ -6133,7 +6131,7 @@ definitions:
61336131
type: array
61346132
items:
61356133
$ref: '#/definitions/Milestone'
6136-
6134+
61376135
MilestoneTemplateRequest:
61386136
title: Milestone template request object
61396137
type: object
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- UPDATE EXISTING projects table
2+
-- modify column `terms`
3+
4+
-- drop existent column first to avoid any issues during type convertion as we don't need the data if there is any
5+
ALTER TABLE projects DROP COLUMN "terms";
6+
-- now create a column with a new type
7+
ALTER TABLE projects ADD COLUMN "terms" character varying(255)[] NOT NULL DEFAULT ARRAY[]::character varying[]::character varying(255)[];

src/events/projects/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const projectPayloadSchema = Joi.object().keys({
102102
id: Joi.number().integer().positive().required(),
103103
createdAt: Joi.date().required(),
104104
updatedAt: Joi.date().required(),
105-
terms: Joi.array().items(Joi.number().positive()).optional(),
105+
terms: Joi.array().items(Joi.string()).optional(),
106106
name: Joi.string().required(),
107107
description: Joi.string().allow(null).allow('').optional(),
108108
type: Joi.string().max(45).required(),

src/models/project.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = function defineProject(sequelize, DataTypes) {
1616
estimatedPrice: { type: DataTypes.DECIMAL(10, 2), allowNull: true },
1717
actualPrice: { type: DataTypes.DECIMAL(10, 2), allowNull: true },
1818
terms: {
19-
type: DataTypes.ARRAY(DataTypes.INTEGER),
19+
type: DataTypes.ARRAY(DataTypes.STRING),
2020
allowNull: false,
2121
defaultValue: [],
2222
},

src/routes/projects/create.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const createProjectValidations = {
4545
})).optional().allow(null),
4646
estimatedPrice: Joi.number().precision(2).positive().optional()
4747
.allow(null),
48-
terms: Joi.array().items(Joi.number().positive()).optional(),
48+
terms: Joi.array().items(Joi.string()).optional(),
4949
external: Joi.object().keys({
5050
id: Joi.string(),
5151
type: Joi.any().valid('github', 'jira', 'asana', 'other'),

src/routes/projects/update.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const updateProjectValdiations = {
4646
status: Joi.any().valid(_.values(PROJECT_STATUS)),
4747
estimatedPrice: Joi.number().precision(2).positive().allow(null),
4848
actualPrice: Joi.number().precision(2).positive(),
49-
terms: Joi.array().items(Joi.number().positive()),
49+
terms: Joi.array().items(Joi.string()),
5050
external: Joi.object().keys({
5151
id: Joi.string(),
5252
type: Joi.any().valid('github', 'jira', 'asana', 'other'),

src/routes/projects/update.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ describe('Project', () => {
983983
Authorization: `Bearer ${testUtil.jwts.admin}`,
984984
})
985985
.send({
986-
terms: [1, 2, 3],
986+
terms: ['1', '2', '3'],
987987
})
988988
.expect(200)
989989
.end((err) => {
@@ -996,7 +996,7 @@ describe('Project', () => {
996996
createEventSpy.calledWith(BUS_API_EVENT.PROJECT_UPDATED, sinon.match({
997997
resource: 'project',
998998
id: project1.id,
999-
terms: [1, 2, 3],
999+
terms: ['1', '2', '3'],
10001000
updatedBy: testUtil.userIds.admin,
10011001
})).should.be.true;
10021002

src/utils/es-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ MAPPINGS[ES_PROJECT_INDEX] = {
320320
index: 'not_analyzed',
321321
},
322322
terms: {
323-
type: 'integer',
323+
type: 'string',
324324
},
325325
type: {
326326
type: 'string',

0 commit comments

Comments
 (0)