Commit 3bd099c3 authored by Piotr Gawron's avatar Piotr Gawron

Merge branch '902-privileges-migration-for-users' into 'master'

Resolve "Privileges migration for USERS"

Closes #902

See merge request !947
parents b311c53c baeb3dff
Pipeline #14038 canceled with stage
in 3 minutes and 1 second
......@@ -21,7 +21,9 @@ minerva (14.0.0~beta.2) unstable; urgency=low
create data overlay (#939)
* Bug fix: export to CD could misalign reaction lines that were imported from
format that didn't require reaction line to be attached to the species (#933)
* Bug fix: problem with uploading data_overlays with type included in header
* Bug fix: problem with migration of default privileges (#902)
* Bug fix: some project privileges were not migrated properly (#902)
* Bug fix: problem with uploading data_overlays with type included in header
(#936)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 16 Sep 2019 21:00:00 +0200
......
......@@ -23,6 +23,13 @@ insert into privilege_table (type, object_id)
select 'WRITE_PROJECT', id
from project_table;
--defaults for project
insert into privilege_table (type, object_id)
values ('WRITE_PROJECT', null);
insert into privilege_table (type, object_id)
values ('READ_PROJECT', null);
create table user_privilege_map_table (
user_id integer not null references user_table(id),
privilege_id integer not null references privilege_table(id)
......@@ -34,6 +41,18 @@ from (select user_id, object_id from privilege_table where type = 'VIEW_PROJECT'
inner join (select id, object_id from privilege_table where type = 'READ_PROJECT') s2
on s1.object_id = s2.object_id;
--default read
insert into user_privilege_map_table (user_id, privilege_id)
select s1.user_id, s2.id
from (select user_id from privilege_table where type = 'VIEW_PROJECT' and object_id is null) s1,
(select id from privilege_table where type = 'READ_PROJECT' and object_id is null) s2;
--default write
insert into user_privilege_map_table (user_id, privilege_id)
select s1.user_id, s2.id
from (select distinct(user_id) from privilege_table where (type = 'EDIT_COMMENTS_PROJECT' or type = 'LAYOUT_MANAGEMENT') and object_id is null) s1,
(select id from privilege_table where type = 'WRITE_PROJECT' and object_id is null) s2;
insert into user_privilege_map_table (user_id, privilege_id)
select s1.user_id, s2.id
from (select user_id, object_id from privilege_table where type = 'EDIT_COMMENTS_PROJECT' or type = 'LAYOUT_MANAGEMENT') s1
......@@ -71,7 +90,7 @@ delete from privilege_table where type = 'VIEW_PROJECT'
or type = 'MANAGE_PLUGINS';
delete from user_privilege_map_table t1 using user_privilege_map_table t2
where t1.CTID != t2.CTID
where t1.CTID < t2.CTID
and t1.user_id = t2.user_id
and t1.privilege_id = t2.privilege_id;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment