diff --git a/CHANGELOG b/CHANGELOG index 7a2ede31e6197ba7724a59873f966db664d43bfb..71e89397ad23c0498c3c163b201a70c7b25a0275 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/persist/src/main/resources/db/migration/14.0.0~alpha.0/V14.0.0.20190618__new_permission_model.sql b/persist/src/main/resources/db/migration/14.0.0~alpha.0/V14.0.0.20190618__new_permission_model.sql index 37b6f26808c5cd97ce09a1cb465c049a92a5919a..fc661c0e05e8a4baec8f24913ccb3e5729962cf4 100644 --- a/persist/src/main/resources/db/migration/14.0.0~alpha.0/V14.0.0.20190618__new_permission_model.sql +++ b/persist/src/main/resources/db/migration/14.0.0~alpha.0/V14.0.0.20190618__new_permission_model.sql @@ -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;