-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(permissions) added amigration to add the import permission for th…
…ose that already passed the migrations
- Loading branch information
1 parent
986cc28
commit 729799e
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
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
63 changes: 63 additions & 0 deletions
63
backend/gn_module_import/migrations/d6bf8eaf088c_add_update_permission.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,63 @@ | ||
"""add update permission | ||
Revision ID: d6bf8eaf088c | ||
Revises: 8611f7aab8dc | ||
Create Date: 2023-09-18 11:29:42.145359 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'd6bf8eaf088c' | ||
down_revision = '8611f7aab8dc' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.execute( | ||
""" | ||
INSERT INTO | ||
gn_permissions.t_permissions_available ( | ||
id_module, | ||
id_object, | ||
id_action, | ||
label, | ||
scope_filter | ||
) | ||
SELECT | ||
m.id_module, | ||
o.id_object, | ||
a.id_action, | ||
v.label, | ||
v.scope_filter | ||
FROM | ||
( | ||
VALUES | ||
('IMPORT', 'IMPORT', 'U', True, 'Modifier des imports') | ||
) AS v (module_code, object_code, action_code, scope_filter, label) | ||
JOIN | ||
gn_commons.t_modules m ON m.module_code = v.module_code | ||
JOIN | ||
gn_permissions.t_objects o ON o.code_object = v.object_code | ||
JOIN | ||
gn_permissions.bib_actions a ON a.code_action = v.action_code | ||
WHERE | ||
NOT EXISTS ( | ||
SELECT | ||
label | ||
FROM | ||
gn_permissions.t_permissions_available av | ||
WHERE | ||
av.id_module = m.id_module AND | ||
av.id_object = o.id_object AND | ||
av.id_action = a.id_action | ||
); | ||
""" | ||
) | ||
|
||
|
||
def downgrade(): | ||
pass |