Skip to content

Commit d85a881

Browse files
committed
fix: ajustes nos scripts sql #64
1 parent fe5ea66 commit d85a881

File tree

3 files changed

+92
-192
lines changed

3 files changed

+92
-192
lines changed

create.sql

Lines changed: 83 additions & 188 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

2-
create table attribution (
2+
create table apf.attribution (
33
attrib_id serial not null,
44
attrib_name varchar(255),
55
primary key (attrib_id)
66
);
77

8-
create table data_function (
8+
create table apf.data_function (
99
data_id bigserial not null,
1010
det int8,
1111
description varchar(255),
@@ -17,7 +17,7 @@
1717
primary key (data_id)
1818
);
1919

20-
create table member (
20+
create table apf.member (
2121
member_id bigserial not null,
2222
created_on date not null,
2323
attrib_id int4 not null,
@@ -26,7 +26,7 @@
2626
primary key (member_id)
2727
);
2828

29-
create table project (
29+
create table apf.project (
3030
project_id bigserial not null,
3131
active int4,
3232
created_on date not null,
@@ -36,13 +36,13 @@
3636
primary key (project_id)
3737
);
3838

39-
create table role (
39+
create table apf.role (
4040
role_id serial not null,
4141
role_name varchar(255),
4242
primary key (role_id)
4343
);
4444

45-
create table transaction_function (
45+
create table apf.transaction_function (
4646
trans_id bigserial not null,
4747
det int4,
4848
description varchar(255),
@@ -54,159 +54,99 @@
5454
primary key (trans_id)
5555
);
5656

57-
create table user_role (
57+
create table apf.user_role (
5858
user_id int8 not null,
5959
role_id int4 not null,
6060
primary key (user_id, role_id)
6161
);
6262

63-
create table user_story (
63+
create table apf.user_story (
6464
user_story_id bigserial not null,
6565
description varchar(255),
6666
name varchar(255),
6767
project_id int8 not null,
6868
primary key (user_story_id)
6969
);
7070

71-
create table users (
71+
create table apf.users (
7272
user_id bigserial not null,
7373
active int4,
7474
email varchar(255),
7575
last_name varchar(255),
76-
name varchar(255),
76+
first_name varchar(255),
7777
password varchar(255),
7878
primary key (user_id)
7979
);
8080

81-
alter table attribution
82-
add constraint UK_ifqougpv1g0br8g67hstq5kxo unique (attrib_name);
83-
84-
alter table project
85-
add constraint UK_3k75vvu7mevyvvb5may5lj8k7 unique (name);
86-
87-
alter table role
88-
add constraint UK_iubw515ff0ugtm28p8g3myt0h unique (role_name);
89-
90-
alter table data_function
91-
add constraint FKre6qmiqtq8jycft6y8vabky55
92-
foreign key (project_id)
93-
references project;
94-
95-
alter table data_function
96-
add constraint FKdlvokmcc2or8dq955n5yisrpo
97-
foreign key (user_story_id)
98-
references user_story;
99-
100-
alter table member
101-
add constraint FKiiq8mj6y0sssha2n9dekhhha
102-
foreign key (attrib_id)
103-
references attribution;
104-
105-
alter table member
106-
add constraint FKn4gkqnpww70e7vcyfh0lt2imn
107-
foreign key (project_id)
108-
references project;
109-
110-
alter table member
111-
add constraint FKe6yo8tn29so0kdd1mw4qk8tgh
112-
foreign key (user_id)
113-
references users;
114-
115-
alter table transaction_function
116-
add constraint FKiwg15idv7boxrkyjn8c961mll
117-
foreign key (project_id)
118-
references project;
119-
120-
alter table transaction_function
121-
add constraint FK2cxqcksbnyda0ata54ubjne98
122-
foreign key (user_story_id)
123-
references user_story;
124-
125-
alter table user_role
126-
add constraint FKa68196081fvovjhkek5m97n3y
127-
foreign key (role_id)
128-
references role;
129-
130-
alter table user_role
131-
add constraint FKj345gk1bovqvfame88rcx7yyx
132-
foreign key (user_id)
133-
references users;
134-
135-
alter table user_story
136-
add constraint FKwswc3uhx3p0yuscuxsqh2ywt
137-
foreign key (project_id)
138-
references project;
139-
140-
create table attribution (
141-
attrib_id serial not null,
142-
attrib_name varchar(255),
143-
primary key (attrib_id)
144-
);
145-
146-
create table data_function (
147-
data_id bigserial not null,
148-
det int8,
149-
description varchar(255),
150-
name varchar(255) not null,
151-
ret int8,
152-
type varchar(255) not null,
153-
project_id int8,
154-
user_story_id int8,
155-
primary key (data_id)
156-
);
157-
158-
create table member (
159-
member_id bigserial not null,
160-
created_on date not null,
161-
attrib_id int4 not null,
162-
project_id int8 not null,
163-
user_id int8 not null,
164-
primary key (member_id)
165-
);
81+
alter table apf.attribution
82+
drop constraint UK_ifqougpv1g0br8g67hstq5kxo;
16683

167-
create table project (
168-
project_id bigserial not null,
169-
active int4,
170-
created_on date not null,
171-
description varchar(255) not null,
172-
is_private boolean not null,
173-
name varchar(255),
174-
primary key (project_id)
175-
);
84+
alter table apf.attribution
85+
add constraint UK_ifqougpv1g0br8g67hstq5kxo unique (attrib_name);
17686

177-
create table role (
178-
role_id serial not null,
179-
role_name varchar(255),
180-
primary key (role_id)
181-
);
87+
alter table apf.project
88+
drop constraint UK_3k75vvu7mevyvvb5may5lj8k7;
18289

183-
create table transaction_function (
184-
trans_id bigserial not null,
185-
det int4,
186-
description varchar(255),
187-
ftr int4,
188-
name varchar(255) not null,
189-
type varchar(255) not null,
190-
project_id int8,
191-
user_story_id int8,
192-
primary key (trans_id)
193-
);
90+
alter table apf.project
91+
add constraint UK_3k75vvu7mevyvvb5may5lj8k7 unique (name);
19492

195-
create table user_role (
196-
user_id int8 not null,
197-
role_id int4 not null,
198-
primary key (user_id, role_id)
199-
);
93+
alter table apf.role
94+
drop constraint UK_iubw515ff0ugtm28p8g3myt0h;
20095

201-
create table user_story (
202-
user_story_id bigserial not null,
203-
description varchar(255),
204-
name varchar(255),
205-
project_id int8 not null,
206-
primary key (user_story_id)
207-
);
96+
alter table apf.role
97+
add constraint UK_iubw515ff0ugtm28p8g3myt0h unique (role_name);
20898

209-
create table users (
99+
alter table apf.data_function
100+
add constraint FKre6qmiqtq8jycft6y8vabky55
101+
foreign key (project_id)
102+
references apf.project;
103+
104+
alter table apf.data_function
105+
add constraint FKdlvokmcc2or8dq955n5yisrpo
106+
foreign key (user_story_id)
107+
references apf.user_story;
108+
109+
alter table apf.member
110+
add constraint FKiiq8mj6y0sssha2n9dekhhha
111+
foreign key (attrib_id)
112+
references apf.attribution;
113+
114+
alter table apf.member
115+
add constraint FKn4gkqnpww70e7vcyfh0lt2imn
116+
foreign key (project_id)
117+
references apf.project;
118+
119+
alter table apf.member
120+
add constraint FKe6yo8tn29so0kdd1mw4qk8tgh
121+
foreign key (user_id)
122+
references apf.users;
123+
124+
alter table apf.transaction_function
125+
add constraint FKiwg15idv7boxrkyjn8c961mll
126+
foreign key (project_id)
127+
references apf.project;
128+
129+
alter table apf.transaction_function
130+
add constraint FK2cxqcksbnyda0ata54ubjne98
131+
foreign key (user_story_id)
132+
references apf.user_story;
133+
134+
alter table apf.user_role
135+
add constraint FKa68196081fvovjhkek5m97n3y
136+
foreign key (role_id)
137+
references apf.role;
138+
139+
alter table apf.user_role
140+
add constraint FKj345gk1bovqvfame88rcx7yyx
141+
foreign key (user_id)
142+
references apf.users;
143+
144+
alter table apf.user_story
145+
add constraint FKwswc3uhx3p0yuscuxsqh2ywt
146+
foreign key (project_id)
147+
references apf.project;
148+
149+
create table apf.apf_users (
210150
user_id bigserial not null,
211151
active int4,
212152
email varchar(255),
@@ -216,61 +156,16 @@
216156
primary key (user_id)
217157
);
218158

219-
alter table attribution
220-
add constraint UK_ifqougpv1g0br8g67hstq5kxo unique (attrib_name);
221-
222-
alter table project
223-
add constraint UK_3k75vvu7mevyvvb5may5lj8k7 unique (name);
224-
225-
alter table role
226-
add constraint UK_iubw515ff0ugtm28p8g3myt0h unique (role_name);
227-
228-
alter table data_function
229-
add constraint FKre6qmiqtq8jycft6y8vabky55
230-
foreign key (project_id)
231-
references project;
232-
233-
alter table data_function
234-
add constraint FKdlvokmcc2or8dq955n5yisrpo
235-
foreign key (user_story_id)
236-
references user_story;
237-
238-
alter table member
239-
add constraint FKiiq8mj6y0sssha2n9dekhhha
240-
foreign key (attrib_id)
241-
references attribution;
242-
243-
alter table member
244-
add constraint FKn4gkqnpww70e7vcyfh0lt2imn
245-
foreign key (project_id)
246-
references project;
247-
248-
alter table member
249-
add constraint FKe6yo8tn29so0kdd1mw4qk8tgh
250-
foreign key (user_id)
251-
references users;
252-
253-
alter table transaction_function
254-
add constraint FKiwg15idv7boxrkyjn8c961mll
255-
foreign key (project_id)
256-
references project;
257-
258-
alter table transaction_function
259-
add constraint FK2cxqcksbnyda0ata54ubjne98
260-
foreign key (user_story_id)
261-
references user_story;
159+
alter table apf.member
160+
add constraint FK9cgbjp4qijgbb1v615civeso2
161+
foreign key (user_id)
162+
references apf.apf_users;
262163

263-
alter table user_role
264-
add constraint FKa68196081fvovjhkek5m97n3y
265-
foreign key (role_id)
266-
references role;
164+
alter table apf.user_role
165+
add constraint FKa835ft3kmwwybwlus4ld9lqev
166+
foreign key (user_id)
167+
references apf.apf_users;
267168

268-
alter table user_role
269-
add constraint FKj345gk1bovqvfame88rcx7yyx
270-
foreign key (user_id)
271-
references users;
169+
alter table apf.users
170+
add column first_name varchar(255);
272171

273-
alter table user_story
274-
add constraint FKwswc3uhx3p0yuscuxsqh2ywt
275-
foreign key (project_id)
276-
references project;

db/insert_postgres.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ INSERT INTO apf.attribution VALUES (2,'PROJECT MEMBER');
66

77
/* password = 123456 */
88
INSERT INTO apf.user (active,email,last_name,name,password) VALUES (
9-
1,'admin@apf.ceres.ufrn.br','APF Owner','Admin',
10-
'$2a$10$RPOEaqsA96T624umYNHMOe3ucdphFSOL1XYmWZckqmQoiSBAzV9ba');
9+
1,'admin@apf.labens.dct.ufrn.br','APF Owner','Admin',
10+
'$2a$10$nx44XCHE.4LNfFCU/O0oBOVQk2Flb7MvhlQjMmnw/T8vOxc2KwM82');
1111

12-
INSERT INTO apf.user_role(user_id, role_id) VALUES ((select user_id from apf.user where email = 'admin@apf.ceres.ufrn.br'), 1);
13-
INSERT INTO apf.user_role(user_id, role_id) VALUES ((select user_id from apf.user where email = 'admin@apf.ceres.ufrn.br'), 2);
12+
INSERT INTO apf.user_role(user_id, role_id) VALUES ((select user_id from apf.user where email = 'admin@apf.labens.dct.ufrn.br'), 1);
13+
INSERT INTO apf.user_role(user_id, role_id) VALUES ((select user_id from apf.user where email = 'admin@apf.labens.dct.ufrn.br'), 2);
1414

1515
INSERT INTO apf.project (active,created_on,description,name,is_private) VALUES (
1616
1,'2019-04-30','Analisador de Pontos de Função','APF Oficial', '0');

src/test/resources/data.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
INSERT INTO role VALUES (1,'ADMIN');
2+
INSERT INTO role VALUES (2,'USER');
3+
4+
INSERT INTO attribution VALUES (1,'PROJECT MANAGER');
5+
INSERT INTO attribution VALUES (2,'PROJECT MEMBER');

0 commit comments

Comments
 (0)