Commit 6f719346 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

migrate defaults

parent 76740d17
......@@ -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
......
Supports Markdown
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