Skip to content

Commit 9df0aca

Browse files
author
vikasrohit
authored
Merge pull request #373 from topcoder-platform/feature/price-estimation-items/merged
Data model for spend price per building blocks and project settings
2 parents cf0c088 + 70d70d8 commit 9df0aca

28 files changed

+3928
-5
lines changed

local/seed/seedProjects.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import util from '../../src/tests/util';
2+
import models from '../../src/models';
23

34
const axios = require('axios');
45
const Promise = require('bluebird');
@@ -54,6 +55,21 @@ module.exports = (targetUrl, token) => {
5455
});
5556
}
5657

58+
await models.ProjectEstimation.create({
59+
projectId,
60+
buildingBlockKey: 'BLOCK_KEY',
61+
conditions: '( HAS_DEV_DELIVERABLE && ONLY_ONE_OS_MOBILE && CA_NEEDED )',
62+
price: 6500.50,
63+
quantity: 10,
64+
minTime: 35,
65+
maxTime: 35,
66+
metadata: {
67+
deliverable: 'dev-qa',
68+
},
69+
createdBy: 1,
70+
updatedBy: 1,
71+
});
72+
5773
// creating invitations
5874
if (Array.isArray(invites)) {
5975
let promises = []
@@ -134,4 +150,3 @@ function updateProjectMemberInvite(projectId, params, targetUrl, headers) {
134150
console.log(`Failed to update project member invites ${projectId}: ${err.message}`);
135151
})
136152
}
137-
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
-- CREATE NEW TABLES:
2+
-- project_settings
3+
-- project_estimation_items
4+
--
5+
6+
--
7+
-- project_settings
8+
--
9+
10+
CREATE TABLE project_settings (
11+
id bigint NOT NULL,
12+
key character varying(255),
13+
value character varying(255),
14+
"valueType" character varying(255),
15+
"projectId" bigint NOT NULL,
16+
metadata json NOT NULL DEFAULT '{}'::json,
17+
"readPermission" json NOT NULL DEFAULT '{}'::json,
18+
"writePermission" json NOT NULL DEFAULT '{}'::json,
19+
"deletedAt" timestamp with time zone,
20+
"createdAt" timestamp with time zone,
21+
"updatedAt" timestamp with time zone,
22+
"deletedBy" bigint,
23+
"createdBy" bigint NOT NULL,
24+
"updatedBy" bigint NOT NULL,
25+
CONSTRAINT project_settings_pkey PRIMARY KEY (id)
26+
);
27+
28+
CREATE SEQUENCE project_settings_id_seq
29+
START WITH 1
30+
INCREMENT BY 1
31+
NO MINVALUE
32+
NO MAXVALUE
33+
CACHE 1;
34+
35+
ALTER SEQUENCE project_settings_id_seq OWNED BY project_settings.id;
36+
37+
ALTER TABLE project_settings
38+
ALTER COLUMN id SET DEFAULT nextval('project_settings_id_seq');
39+
40+
ALTER TABLE project_settings
41+
ADD CONSTRAINT project_settings_key_project_id UNIQUE (key, "projectId");
42+
43+
--
44+
-- project_estimation_items
45+
--
46+
47+
CREATE TABLE project_estimation_items (
48+
id bigint NOT NULL,
49+
"projectEstimationId" bigint NOT NULL,
50+
price double precision NOT NULL,
51+
type character varying(255) NOT NULL,
52+
"markupUsedReference" character varying(255) NOT NULL,
53+
"markupUsedReferenceId" bigint NOT NULL,
54+
metadata json NOT NULL DEFAULT '{}'::json,
55+
"deletedAt" timestamp with time zone,
56+
"createdAt" timestamp with time zone,
57+
"updatedAt" timestamp with time zone,
58+
"deletedBy" bigint,
59+
"createdBy" bigint NOT NULL,
60+
"updatedBy" bigint NOT NULL,
61+
CONSTRAINT project_estimation_items_pkey PRIMARY KEY (id)
62+
);
63+
64+
CREATE SEQUENCE project_estimation_items_id_seq
65+
START WITH 1
66+
INCREMENT BY 1
67+
NO MINVALUE
68+
NO MAXVALUE
69+
CACHE 1;
70+
71+
ALTER SEQUENCE project_estimation_items_id_seq OWNED BY form.id;
72+
73+
ALTER TABLE project_estimation_items
74+
ALTER COLUMN id SET DEFAULT nextval('project_estimation_items_id_seq');
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--
2+
-- CREATE NEW TABLE:
3+
-- building_blocks
4+
--
5+
CREATE TABLE building_blocks (
6+
id bigint NOT NULL,
7+
"key" character varying(255) NOT NULL,
8+
"config" json NOT NULL DEFAULT '{}'::json,
9+
"privateConfig" json NOT NULL DEFAULT '{}'::json,
10+
"deletedAt" timestamp with time zone,
11+
"createdAt" timestamp with time zone,
12+
"updatedAt" timestamp with time zone,
13+
"deletedBy" bigint,
14+
"createdBy" bigint NOT NULL,
15+
"updatedBy" bigint NOT NULL
16+
);
17+
18+
ALTER TABLE building_blocks
19+
ADD CONSTRAINT building_blocks_key_uniq UNIQUE (key);
20+
21+
CREATE SEQUENCE building_blocks_id_seq
22+
START WITH 1
23+
INCREMENT BY 1
24+
NO MINVALUE
25+
NO MAXVALUE
26+
CACHE 1;
27+
28+
ALTER SEQUENCE building_blocks_id_seq OWNED BY building_blocks.id;
29+
30+
ALTER TABLE building_blocks
31+
ALTER COLUMN id SET DEFAULT nextval('building_blocks_id_seq');
32+
33+
ALTER TABLE ONLY building_blocks
34+
ADD CONSTRAINT building_blocks_pkey PRIMARY KEY (id);
35+

0 commit comments

Comments
 (0)