5 extends
'CXGN::Metadata::Dbpatch';
9 my $name = __PACKAGE__
;
10 say "dbpatch name is $name";
11 my $description = 'Add User Roles';
12 my @previous_requested_patches = (); #ADD HERE
15 $self->description($description);
16 $self->prereq(\
@previous_requested_patches);
23 print "Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
25 print "\nExecuting the SQL commands.\n";
27 $self->dbh->do(<<EOSQL);
29 CREATE TABLE sgn_people.sp_roles (
30 sp_role_id serial primary key,
34 CREATE TABLE sgn_people.sp_person_roles (
35 sp_person_role_id serial primary key,
36 sp_person_id bigint references sgn_people.sp_person on delete cascade,
37 sp_role_id bigint references sgn_people.sp_roles on delete cascade
40 INSERT INTO sgn_people.sp_roles(name) VALUES ('curator');
41 INSERT INTO sgn_people.sp_roles(name) VALUES ('sequencer');
42 INSERT INTO sgn_people.sp_roles(name) VALUES ('submitter');
43 INSERT INTO sgn_people.sp_roles(name) VALUES ('user');
45 INSERT INTO sgn_people.sp_person_roles (sp_role_id, sp_person_id)
46 SELECT sp_role_id, sp_person_id
47 FROM sgn_people.sp_person
48 JOIN sgn_people.sp_roles ON (user_type=name);
50 GRANT select, update, insert, delete ON sgn_people.sp_roles to postgres, web_usr;
51 GRANT select, update, insert, delete ON sgn_people.sp_person_roles to postgres, web_usr;
53 GRANT select, update, usage ON sgn_people.sp_roles_sp_role_id_seq to postgres, web_usr;
55 GRANT select, update, usage ON sgn_people.sp_person_roles_sp_person_role_id_seq to postgres, web_usr;