Removed specific user group and roles. The records must be dynamic.

master
Tudor Stanciu 2023-04-11 19:02:40 +03:00
parent fdb08acd21
commit 74d68f2329
4 changed files with 1 additions and 85 deletions

View File

@ -6,14 +6,4 @@ begin
UserGroupCode varchar(30) not null,
UserGroupName varchar(50) not null
)
end
if not exists (select top 1 1 from UserGroup)
begin
insert into UserGroup(UserGroupCode, UserGroupName)
values ('ADMINISTRATORS', 'Administrators'),
('USERS', 'Users'),
('DEVELOPERS', 'Developers'),
('VIEWERS', 'Viewers'),
('GUESTS', 'Guests')
end

View File

@ -6,17 +6,4 @@ begin
UserRoleCode varchar(30) not null,
UserRoleName varchar(50) not null
)
end
if not exists (select top 1 1 from UserRole)
begin
insert into UserRole(UserRoleCode, UserRoleName)
values ('SYSTEM_ADMINISTRATOR', 'System administrator'),
('FULLSTACK_DEVELOPER', 'Fullstack developer'),
('POWER_USER', 'Power user'),
('REGULAR_USER', 'Regular user'),
('READONLY_USER', 'Readonly user'),
('ANONYMOUS_USER', 'Anonymous user'),
('DEMO_USER', 'Demo user')
end
end

View File

@ -1,58 +0,0 @@
declare @admin_group_id int, @admin_role_id int
select @admin_group_id = UserGroupId from UserGroup where UserGroupCode = 'ADMINISTRATORS'
select @admin_role_id = UserRoleId from UserRole where UserRoleCode = 'SYSTEM_ADMINISTRATOR'
if not exists (select top 1 1 from UserGroupXUserRole where UserGroupId = @admin_group_id and UserRoleId = @admin_role_id)
begin
insert into UserGroupXUserRole (UserGroupId, UserRoleId)
values (@admin_group_id, @admin_role_id)
end
declare @developer_group_id int, @developer_role_id int
select @developer_group_id = UserGroupId from UserGroup where UserGroupCode = 'DEVELOPERS'
select @developer_role_id = UserRoleId from UserRole where UserRoleCode = 'FULLSTACK_DEVELOPER'
if not exists (select top 1 1 from UserGroupXUserRole where UserGroupId = @developer_group_id and UserRoleId = @developer_role_id)
begin
insert into UserGroupXUserRole (UserGroupId, UserRoleId)
values (@developer_group_id, @developer_role_id)
end
declare @user_group_id int, @user_role_id int
select @user_group_id = UserGroupId from UserGroup where UserGroupCode = 'USERS'
select @user_role_id = UserRoleId from UserRole where UserRoleCode = 'REGULAR_USER'
if not exists (select top 1 1 from UserGroupXUserRole where UserGroupId = @user_group_id and UserRoleId = @user_role_id)
begin
insert into UserGroupXUserRole (UserGroupId, UserRoleId)
values (@user_group_id, @user_role_id)
end
declare @viewer_group_id int, @viewer_role_id int
select @viewer_group_id = UserGroupId from UserGroup where UserGroupCode = 'VIEWERS'
select @viewer_role_id = UserRoleId from UserRole where UserRoleCode = 'READONLY_USER'
if not exists (select top 1 1 from UserGroupXUserRole where UserGroupId = @viewer_group_id and UserRoleId = @viewer_role_id)
begin
insert into UserGroupXUserRole (UserGroupId, UserRoleId)
values (@viewer_group_id, @viewer_role_id)
end
declare @guest_group_id int, @guest_role_id int
select @guest_group_id = UserGroupId from UserGroup where UserGroupCode = 'GUESTS'
select @guest_role_id = UserRoleId from UserRole where UserRoleCode = 'ANONYMOUS_USER'
if not exists (select top 1 1 from UserGroupXUserRole where UserGroupId = @guest_group_id and UserRoleId = @guest_role_id)
begin
insert into UserGroupXUserRole (UserGroupId, UserRoleId)
values (@guest_group_id, @guest_role_id)
end

View File

@ -43,9 +43,6 @@
<None Update="Scripts\2.4.0\03.New tables UserXUserGroup UserGroupXUserRole UserXUserRole.sql">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Scripts\2.4.0\04.Link user groups and roles.sql">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>