Skip to content

Commit 4e4e8f5

Browse files
authored
feat(3336): add sha column into jobs table [1] (#601)
1 parent 3bd1eb8 commit 4e4e8f5

File tree

5 files changed

+35
-3
lines changed

5 files changed

+35
-3
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* eslint-disable new-cap */
2+
3+
'use strict';
4+
5+
const prefix = process.env.DATASTORE_SEQUELIZE_PREFIX || '';
6+
const table = `${prefix}jobs`;
7+
8+
module.exports = {
9+
up: async (queryInterface, Sequelize) => {
10+
await queryInterface.sequelize.transaction(async transaction => {
11+
await queryInterface.addColumn(
12+
table,
13+
'sha',
14+
{
15+
type: Sequelize.STRING(40)
16+
},
17+
{ transaction }
18+
);
19+
});
20+
}
21+
};

models/job.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ const MODEL = {
4444

4545
archived: Joi.boolean().description('Flag if the job is archived').example(true).default(false),
4646

47-
templateId: Joi.number().integer().positive().description("Identifier for this job's template").example(123345)
47+
templateId: Joi.number().integer().positive().description("Identifier for this job's template").example(123345),
48+
49+
sha: Joi.string()
50+
.hex()
51+
.length(40)
52+
.optional()
53+
.description('SHA this job was built on')
54+
.example('ccc49349d3cffbd12ea9e3d41521480b4aa5de5f')
4855
};
4956

5057
const EXTENDED_MODEL = {
@@ -98,7 +105,8 @@ module.exports = {
98105
'title',
99106
'createTime',
100107
'url',
101-
'userProfile'
108+
'userProfile',
109+
'sha'
102110
]
103111
)
104112
).label('Get Job'),

test/data/job.get.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ description: build and test the code
55
pipelineId: 76857568576
66
state: ENABLED
77
archived: false
8+
sha: 46f1a0bd5592a2f9244ca321b129902a06b53e03

test/data/job.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ id: 9787687866
33
name: component
44
pipelineId: 9785708
55
state: ENABLED
6+
sha: 46f1a0bd5592a2f9244ca321b129902a06b53e03
67
permutations:
78
- image: node:4
89
commands:

test/models/job.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ describe('model job', () => {
6969
'stateChanger',
7070
'stateChangeTime',
7171
'stateChangeMessage',
72-
'archived'
72+
'archived',
73+
'sha'
7374
];
7475

7576
expectedKeys.forEach(keyName => {

0 commit comments

Comments
 (0)