Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
minerva
core
Commits
6f719346
Commit
6f719346
authored
5 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
migrate defaults
parent
76740d17
No related branches found
No related tags found
1 merge request
!947
Resolve "Privileges migration for USERS"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
persist/src/main/resources/db/migration/14.0.0~alpha.0/V14.0.0.20190618__new_permission_model.sql
+19
-0
19 additions, 0 deletions
...14.0.0~alpha.0/V14.0.0.20190618__new_permission_model.sql
with
19 additions
and
0 deletions
persist/src/main/resources/db/migration/14.0.0~alpha.0/V14.0.0.20190618__new_permission_model.sql
+
19
−
0
View file @
6f719346
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment