-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OP-461: added migration script to apply roles for admin for that module
- Loading branch information
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
contribution_plan/migrations/0009_contributionplan_roles_for_admin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import logging | ||
|
||
from django.db import migrations | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
MIGRATION_SQL = """ | ||
/* Contribution plan and bundle*/ | ||
DECLARE @SystemRole INT | ||
SELECT @SystemRole = role.RoleID from tblRole role where IsSystem=256; | ||
/* Contribution plan bundle*/ | ||
IF NOT EXISTS (SELECT * FROM [tblRoleRight] WHERE [RoleID] = @SystemRole AND [RightID] = 151101) | ||
BEGIN | ||
INSERT [dbo].[tblRoleRight] ([RoleID], [RightID], [ValidityFrom]) | ||
VALUES (@SystemRole, 151101, CURRENT_TIMESTAMP) | ||
END | ||
IF NOT EXISTS (SELECT * FROM [tblRoleRight] WHERE [RoleID] = @SystemRole AND [RightID] = 151102) | ||
BEGIN | ||
INSERT [dbo].[tblRoleRight] ([RoleID], [RightID], [ValidityFrom]) | ||
VALUES (@SystemRole, 151102, CURRENT_TIMESTAMP) | ||
END | ||
IF NOT EXISTS (SELECT * FROM [tblRoleRight] WHERE [RoleID] = @SystemRole AND [RightID] = 151103) | ||
BEGIN | ||
INSERT [dbo].[tblRoleRight] ([RoleID], [RightID], [ValidityFrom]) | ||
VALUES (@SystemRole, 151103, CURRENT_TIMESTAMP) | ||
END | ||
IF NOT EXISTS (SELECT * FROM [tblRoleRight] WHERE [RoleID] = @SystemRole AND [RightID] = 151104) | ||
BEGIN | ||
INSERT [dbo].[tblRoleRight] ([RoleID], [RightID], [ValidityFrom]) | ||
VALUES (@SystemRole, 151104, CURRENT_TIMESTAMP) | ||
END | ||
IF NOT EXISTS (SELECT * FROM [tblRoleRight] WHERE [RoleID] = @SystemRole AND [RightID] = 151106) | ||
BEGIN | ||
INSERT [dbo].[tblRoleRight] ([RoleID], [RightID], [ValidityFrom]) | ||
VALUES (@SystemRole, 151106, CURRENT_TIMESTAMP) | ||
END | ||
/* Contribution plan */ | ||
IF NOT EXISTS (SELECT * FROM [tblRoleRight] WHERE [RoleID] = @SystemRole AND [RightID] = 151201) | ||
BEGIN | ||
INSERT [dbo].[tblRoleRight] ([RoleID], [RightID], [ValidityFrom]) | ||
VALUES (@SystemRole, 151201, CURRENT_TIMESTAMP) | ||
END | ||
IF NOT EXISTS (SELECT * FROM [tblRoleRight] WHERE [RoleID] = @SystemRole AND [RightID] = 151202) | ||
BEGIN | ||
INSERT [dbo].[tblRoleRight] ([RoleID], [RightID], [ValidityFrom]) | ||
VALUES (@SystemRole, 151202, CURRENT_TIMESTAMP) | ||
END | ||
IF NOT EXISTS (SELECT * FROM [tblRoleRight] WHERE [RoleID] = @SystemRole AND [RightID] = 151203) | ||
BEGIN | ||
INSERT [dbo].[tblRoleRight] ([RoleID], [RightID], [ValidityFrom]) | ||
VALUES (@SystemRole, 151203, CURRENT_TIMESTAMP) | ||
END | ||
IF NOT EXISTS (SELECT * FROM [tblRoleRight] WHERE [RoleID] = @SystemRole AND [RightID] = 151204) | ||
BEGIN | ||
INSERT [dbo].[tblRoleRight] ([RoleID], [RightID], [ValidityFrom]) | ||
VALUES (@SystemRole, 151204, CURRENT_TIMESTAMP) | ||
END | ||
IF NOT EXISTS (SELECT * FROM [tblRoleRight] WHERE [RoleID] = @SystemRole AND [RightID] = 151206) | ||
BEGIN | ||
INSERT [dbo].[tblRoleRight] ([RoleID], [RightID], [ValidityFrom]) | ||
VALUES (@SystemRole, 151206, CURRENT_TIMESTAMP) | ||
END | ||
""" | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
('contribution_plan', '0008_historicalpaymentplan_paymentplan') | ||
] | ||
|
||
operations = [ | ||
migrations.RunSQL(MIGRATION_SQL) | ||
] |