screwdriver-data-schema 22.4.4 → 22.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,45 +8,39 @@ const table = `${prefix}stages`;
|
|
|
8
8
|
module.exports = {
|
|
9
9
|
up: async (queryInterface, Sequelize) => {
|
|
10
10
|
await queryInterface.sequelize.transaction(async transaction => {
|
|
11
|
-
|
|
12
|
-
await queryInterface.removeColumn(table, 'groupEventId');
|
|
11
|
+
await queryInterface.removeColumn(table, 'groupEventId', { transaction });
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{ transaction }
|
|
21
|
-
);
|
|
22
|
-
await queryInterface.addColumn(
|
|
23
|
-
table,
|
|
24
|
-
'teardown',
|
|
25
|
-
{
|
|
26
|
-
type: Sequelize.INTEGER
|
|
27
|
-
},
|
|
28
|
-
{ transaction }
|
|
29
|
-
);
|
|
30
|
-
await queryInterface.addColumn(
|
|
31
|
-
table,
|
|
32
|
-
'archived',
|
|
33
|
-
{
|
|
34
|
-
type: Sequelize.BOOLEAN
|
|
35
|
-
},
|
|
36
|
-
{ transaction }
|
|
37
|
-
);
|
|
38
|
-
await queryInterface.removeConstraint(table, `${table}_pipeline_id_name_group_event_id_key`, {
|
|
39
|
-
transaction
|
|
40
|
-
});
|
|
13
|
+
await queryInterface.addConstraint(table, {
|
|
14
|
+
fields: ['pipelineId', 'name'],
|
|
15
|
+
name: `${table}_pipeline_id_name_key`,
|
|
16
|
+
type: 'unique',
|
|
17
|
+
transaction
|
|
18
|
+
});
|
|
41
19
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
20
|
+
await queryInterface.addColumn(
|
|
21
|
+
table,
|
|
22
|
+
'setup',
|
|
23
|
+
{
|
|
24
|
+
type: Sequelize.INTEGER
|
|
25
|
+
},
|
|
26
|
+
{ transaction }
|
|
27
|
+
);
|
|
28
|
+
await queryInterface.addColumn(
|
|
29
|
+
table,
|
|
30
|
+
'teardown',
|
|
31
|
+
{
|
|
32
|
+
type: Sequelize.INTEGER
|
|
33
|
+
},
|
|
34
|
+
{ transaction }
|
|
35
|
+
);
|
|
36
|
+
await queryInterface.addColumn(
|
|
37
|
+
table,
|
|
38
|
+
'archived',
|
|
39
|
+
{
|
|
40
|
+
type: Sequelize.BOOLEAN
|
|
41
|
+
},
|
|
42
|
+
{ transaction }
|
|
43
|
+
);
|
|
50
44
|
});
|
|
51
45
|
}
|
|
52
46
|
};
|
|
@@ -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}stages`;
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
up: async (queryInterface, Sequelize) => {
|
|
10
|
+
await queryInterface.sequelize.transaction(async transaction => {
|
|
11
|
+
await queryInterface.addColumn(
|
|
12
|
+
table,
|
|
13
|
+
'workflowGraph',
|
|
14
|
+
{
|
|
15
|
+
type: Sequelize.TEXT
|
|
16
|
+
},
|
|
17
|
+
{ transaction }
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* eslint-disable new-cap */
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const prefix = process.env.DATASTORE_SEQUELIZE_PREFIX || '';
|
|
6
|
+
const table = `${prefix}stages`;
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
async up(queryInterface, Sequelize) {
|
|
10
|
+
const transaction = await queryInterface.sequelize.transaction();
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
await queryInterface.dropTable(table, {
|
|
14
|
+
transaction
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
await queryInterface.createTable(
|
|
18
|
+
table,
|
|
19
|
+
{
|
|
20
|
+
id: {
|
|
21
|
+
allowNull: false,
|
|
22
|
+
autoIncrement: true,
|
|
23
|
+
primaryKey: true,
|
|
24
|
+
type: Sequelize.INTEGER.UNSIGNED
|
|
25
|
+
},
|
|
26
|
+
pipelineId: {
|
|
27
|
+
type: Sequelize.DOUBLE
|
|
28
|
+
},
|
|
29
|
+
name: {
|
|
30
|
+
type: Sequelize.STRING(64)
|
|
31
|
+
},
|
|
32
|
+
jobIds: {
|
|
33
|
+
type: Sequelize.TEXT
|
|
34
|
+
},
|
|
35
|
+
description: {
|
|
36
|
+
type: Sequelize.STRING(256)
|
|
37
|
+
},
|
|
38
|
+
setup: {
|
|
39
|
+
type: Sequelize.INTEGER
|
|
40
|
+
},
|
|
41
|
+
teardown: {
|
|
42
|
+
type: Sequelize.INTEGER
|
|
43
|
+
},
|
|
44
|
+
archived: {
|
|
45
|
+
type: Sequelize.BOOLEAN
|
|
46
|
+
},
|
|
47
|
+
workflowGraph: {
|
|
48
|
+
type: Sequelize.TEXT
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{ transaction }
|
|
52
|
+
);
|
|
53
|
+
await queryInterface.addConstraint(table, {
|
|
54
|
+
name: `${table}_pipeline_id_name_key`,
|
|
55
|
+
fields: ['pipelineId', 'name'],
|
|
56
|
+
type: 'unique',
|
|
57
|
+
transaction
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
await queryInterface.addIndex(table, {
|
|
61
|
+
name: `${table}_pipeline_id`,
|
|
62
|
+
fields: ['pipelineId'],
|
|
63
|
+
transaction
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
await transaction.commit();
|
|
67
|
+
} catch (e) {
|
|
68
|
+
await transaction.rollback();
|
|
69
|
+
throw e;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
package/models/stage.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const Joi = require('joi');
|
|
4
4
|
const Regex = require('../config/regex');
|
|
5
|
+
const WorkflowGraph = require('../config/workflowGraph');
|
|
5
6
|
const mutate = require('../lib/mutate');
|
|
6
7
|
|
|
7
8
|
const MODEL = {
|
|
@@ -25,7 +26,15 @@ const MODEL = {
|
|
|
25
26
|
|
|
26
27
|
description: Joi.string().max(256).description('Description of the Stage').example('Deploys canary jobs'),
|
|
27
28
|
|
|
28
|
-
archived: Joi.boolean().description('Flag if the stage is archived').example(true).default(false)
|
|
29
|
+
archived: Joi.boolean().description('Flag if the stage is archived').example(true).default(false),
|
|
30
|
+
|
|
31
|
+
workflowGraph: WorkflowGraph.workflowGraph.description('Graph representation of the workflow').example({
|
|
32
|
+
nodes: [{ name: '~commit' }, { name: 'main' }, { name: 'publish' }],
|
|
33
|
+
edges: [
|
|
34
|
+
{ src: '~commit', dest: 'main' },
|
|
35
|
+
{ src: 'main', dest: 'publish' }
|
|
36
|
+
]
|
|
37
|
+
})
|
|
29
38
|
};
|
|
30
39
|
|
|
31
40
|
module.exports = {
|
|
@@ -52,7 +61,11 @@ module.exports = {
|
|
|
52
61
|
* @type {Joi}
|
|
53
62
|
*/
|
|
54
63
|
get: Joi.object(
|
|
55
|
-
mutate(
|
|
64
|
+
mutate(
|
|
65
|
+
MODEL,
|
|
66
|
+
['id', 'pipelineId', 'name', 'jobIds'],
|
|
67
|
+
['description', 'setup', 'teardown', 'archived', 'workflowGraph']
|
|
68
|
+
)
|
|
56
69
|
).label('Get Stage metadata'),
|
|
57
70
|
|
|
58
71
|
/**
|
|
@@ -61,9 +74,9 @@ module.exports = {
|
|
|
61
74
|
* @property update
|
|
62
75
|
* @type {Joi}
|
|
63
76
|
*/
|
|
64
|
-
update: Joi.object(
|
|
65
|
-
'
|
|
66
|
-
),
|
|
77
|
+
update: Joi.object(
|
|
78
|
+
mutate(MODEL, [], ['jobIds', 'description', 'setup', 'teardown', 'archived', 'workflowGraph'])
|
|
79
|
+
).label('Update Stage'),
|
|
67
80
|
|
|
68
81
|
/**
|
|
69
82
|
* List of fields that determine a unique row
|