Skip to content

Commit

Permalink
fix: ajustes nos scripts sql #64
Browse files Browse the repository at this point in the history
  • Loading branch information
tacianosilva committed Apr 19, 2024
1 parent fe5ea66 commit d85a881
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 192 deletions.
271 changes: 83 additions & 188 deletions create.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

create table attribution (
create table apf.attribution (
attrib_id serial not null,
attrib_name varchar(255),
primary key (attrib_id)
);

create table data_function (
create table apf.data_function (
data_id bigserial not null,
det int8,
description varchar(255),
Expand All @@ -17,7 +17,7 @@
primary key (data_id)
);

create table member (
create table apf.member (
member_id bigserial not null,
created_on date not null,
attrib_id int4 not null,
Expand All @@ -26,7 +26,7 @@
primary key (member_id)
);

create table project (
create table apf.project (
project_id bigserial not null,
active int4,
created_on date not null,
Expand All @@ -36,13 +36,13 @@
primary key (project_id)
);

create table role (
create table apf.role (
role_id serial not null,
role_name varchar(255),
primary key (role_id)
);

create table transaction_function (
create table apf.transaction_function (
trans_id bigserial not null,
det int4,
description varchar(255),
Expand All @@ -54,159 +54,99 @@
primary key (trans_id)
);

create table user_role (
create table apf.user_role (
user_id int8 not null,
role_id int4 not null,
primary key (user_id, role_id)
);

create table user_story (
create table apf.user_story (
user_story_id bigserial not null,
description varchar(255),
name varchar(255),
project_id int8 not null,
primary key (user_story_id)
);

create table users (
create table apf.users (
user_id bigserial not null,
active int4,
email varchar(255),
last_name varchar(255),
name varchar(255),
first_name varchar(255),
password varchar(255),
primary key (user_id)
);

alter table attribution
add constraint UK_ifqougpv1g0br8g67hstq5kxo unique (attrib_name);

alter table project
add constraint UK_3k75vvu7mevyvvb5may5lj8k7 unique (name);

alter table role
add constraint UK_iubw515ff0ugtm28p8g3myt0h unique (role_name);

alter table data_function
add constraint FKre6qmiqtq8jycft6y8vabky55
foreign key (project_id)
references project;

alter table data_function
add constraint FKdlvokmcc2or8dq955n5yisrpo
foreign key (user_story_id)
references user_story;

alter table member
add constraint FKiiq8mj6y0sssha2n9dekhhha
foreign key (attrib_id)
references attribution;

alter table member
add constraint FKn4gkqnpww70e7vcyfh0lt2imn
foreign key (project_id)
references project;

alter table member
add constraint FKe6yo8tn29so0kdd1mw4qk8tgh
foreign key (user_id)
references users;

alter table transaction_function
add constraint FKiwg15idv7boxrkyjn8c961mll
foreign key (project_id)
references project;

alter table transaction_function
add constraint FK2cxqcksbnyda0ata54ubjne98
foreign key (user_story_id)
references user_story;

alter table user_role
add constraint FKa68196081fvovjhkek5m97n3y
foreign key (role_id)
references role;

alter table user_role
add constraint FKj345gk1bovqvfame88rcx7yyx
foreign key (user_id)
references users;

alter table user_story
add constraint FKwswc3uhx3p0yuscuxsqh2ywt
foreign key (project_id)
references project;

create table attribution (
attrib_id serial not null,
attrib_name varchar(255),
primary key (attrib_id)
);

create table data_function (
data_id bigserial not null,
det int8,
description varchar(255),
name varchar(255) not null,
ret int8,
type varchar(255) not null,
project_id int8,
user_story_id int8,
primary key (data_id)
);

create table member (
member_id bigserial not null,
created_on date not null,
attrib_id int4 not null,
project_id int8 not null,
user_id int8 not null,
primary key (member_id)
);
alter table apf.attribution
drop constraint UK_ifqougpv1g0br8g67hstq5kxo;

create table project (
project_id bigserial not null,
active int4,
created_on date not null,
description varchar(255) not null,
is_private boolean not null,
name varchar(255),
primary key (project_id)
);
alter table apf.attribution
add constraint UK_ifqougpv1g0br8g67hstq5kxo unique (attrib_name);

create table role (
role_id serial not null,
role_name varchar(255),
primary key (role_id)
);
alter table apf.project
drop constraint UK_3k75vvu7mevyvvb5may5lj8k7;

create table transaction_function (
trans_id bigserial not null,
det int4,
description varchar(255),
ftr int4,
name varchar(255) not null,
type varchar(255) not null,
project_id int8,
user_story_id int8,
primary key (trans_id)
);
alter table apf.project
add constraint UK_3k75vvu7mevyvvb5may5lj8k7 unique (name);

create table user_role (
user_id int8 not null,
role_id int4 not null,
primary key (user_id, role_id)
);
alter table apf.role
drop constraint UK_iubw515ff0ugtm28p8g3myt0h;

create table user_story (
user_story_id bigserial not null,
description varchar(255),
name varchar(255),
project_id int8 not null,
primary key (user_story_id)
);
alter table apf.role
add constraint UK_iubw515ff0ugtm28p8g3myt0h unique (role_name);

create table users (
alter table apf.data_function
add constraint FKre6qmiqtq8jycft6y8vabky55
foreign key (project_id)
references apf.project;

alter table apf.data_function
add constraint FKdlvokmcc2or8dq955n5yisrpo
foreign key (user_story_id)
references apf.user_story;

alter table apf.member
add constraint FKiiq8mj6y0sssha2n9dekhhha
foreign key (attrib_id)
references apf.attribution;

alter table apf.member
add constraint FKn4gkqnpww70e7vcyfh0lt2imn
foreign key (project_id)
references apf.project;

alter table apf.member
add constraint FKe6yo8tn29so0kdd1mw4qk8tgh
foreign key (user_id)
references apf.users;

alter table apf.transaction_function
add constraint FKiwg15idv7boxrkyjn8c961mll
foreign key (project_id)
references apf.project;

alter table apf.transaction_function
add constraint FK2cxqcksbnyda0ata54ubjne98
foreign key (user_story_id)
references apf.user_story;

alter table apf.user_role
add constraint FKa68196081fvovjhkek5m97n3y
foreign key (role_id)
references apf.role;

alter table apf.user_role
add constraint FKj345gk1bovqvfame88rcx7yyx
foreign key (user_id)
references apf.users;

alter table apf.user_story
add constraint FKwswc3uhx3p0yuscuxsqh2ywt
foreign key (project_id)
references apf.project;

create table apf.apf_users (
user_id bigserial not null,
active int4,
email varchar(255),
Expand All @@ -216,61 +156,16 @@
primary key (user_id)
);

alter table attribution
add constraint UK_ifqougpv1g0br8g67hstq5kxo unique (attrib_name);

alter table project
add constraint UK_3k75vvu7mevyvvb5may5lj8k7 unique (name);

alter table role
add constraint UK_iubw515ff0ugtm28p8g3myt0h unique (role_name);

alter table data_function
add constraint FKre6qmiqtq8jycft6y8vabky55
foreign key (project_id)
references project;

alter table data_function
add constraint FKdlvokmcc2or8dq955n5yisrpo
foreign key (user_story_id)
references user_story;

alter table member
add constraint FKiiq8mj6y0sssha2n9dekhhha
foreign key (attrib_id)
references attribution;

alter table member
add constraint FKn4gkqnpww70e7vcyfh0lt2imn
foreign key (project_id)
references project;

alter table member
add constraint FKe6yo8tn29so0kdd1mw4qk8tgh
foreign key (user_id)
references users;

alter table transaction_function
add constraint FKiwg15idv7boxrkyjn8c961mll
foreign key (project_id)
references project;

alter table transaction_function
add constraint FK2cxqcksbnyda0ata54ubjne98
foreign key (user_story_id)
references user_story;
alter table apf.member
add constraint FK9cgbjp4qijgbb1v615civeso2
foreign key (user_id)
references apf.apf_users;

alter table user_role
add constraint FKa68196081fvovjhkek5m97n3y
foreign key (role_id)
references role;
alter table apf.user_role
add constraint FKa835ft3kmwwybwlus4ld9lqev
foreign key (user_id)
references apf.apf_users;

alter table user_role
add constraint FKj345gk1bovqvfame88rcx7yyx
foreign key (user_id)
references users;
alter table apf.users
add column first_name varchar(255);

alter table user_story
add constraint FKwswc3uhx3p0yuscuxsqh2ywt
foreign key (project_id)
references project;
8 changes: 4 additions & 4 deletions db/insert_postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ INSERT INTO apf.attribution VALUES (2,'PROJECT MEMBER');

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

INSERT INTO apf.user_role(user_id, role_id) VALUES ((select user_id from apf.user where email = 'admin@apf.ceres.ufrn.br'), 1);
INSERT INTO apf.user_role(user_id, role_id) VALUES ((select user_id from apf.user where email = 'admin@apf.ceres.ufrn.br'), 2);
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);
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);

INSERT INTO apf.project (active,created_on,description,name,is_private) VALUES (
1,'2019-04-30','Analisador de Pontos de Função','APF Oficial', '0');
Expand Down
5 changes: 5 additions & 0 deletions src/test/resources/data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
INSERT INTO role VALUES (1,'ADMIN');
INSERT INTO role VALUES (2,'USER');

INSERT INTO attribution VALUES (1,'PROJECT MANAGER');
INSERT INTO attribution VALUES (2,'PROJECT MEMBER');

0 comments on commit d85a881

Please sign in to comment.