diff options
author | Frederick Muriuki Muriithi | 2023-11-23 07:22:09 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-11-23 07:22:09 +0300 |
commit | 24a66e814fabcce19d2bf6fb48186f5bc86fff38 (patch) | |
tree | 7c2827a2c5cd0c204aa5dad4dc2a85e471831b95 /gn_auth/auth/authorisation/resources/models.py | |
parent | 410d797535fc9a9f432c44a7d6c786fd508066c5 (diff) | |
download | gn-auth-24a66e814fabcce19d2bf6fb48186f5bc86fff38.tar.gz |
Scripts: Update script for newer db schema
The schema changed a while back, and the script that is used to make
all existing data public needs to be updated for the new schema. This
commit does exactly that.
Diffstat (limited to 'gn_auth/auth/authorisation/resources/models.py')
-rw-r--r-- | gn_auth/auth/authorisation/resources/models.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/gn_auth/auth/authorisation/resources/models.py b/gn_auth/auth/authorisation/resources/models.py index 15bb72f..d6e3a1d 100644 --- a/gn_auth/auth/authorisation/resources/models.py +++ b/gn_auth/auth/authorisation/resources/models.py @@ -54,13 +54,14 @@ def __assign_resource_owner_role__(cursor, resource, user, group): "role_id": role["role_id"]}) cursor.execute( - "INSERT INTO user_roles " - "VALUES (:user_id, :role_id, :resource_id)", - { - "user_id": str(user.user_id), - "role_id": role["role_id"], - "resource_id": str(resource.resource_id) - }) + "INSERT INTO user_roles " + "VALUES (:user_id, :role_id, :resource_id) " + "ON CONFLICT (user_id, role_id, resource_id) DO NOTHING", + { + "user_id": str(user.user_id), + "role_id": role["role_id"], + "resource_id": str(resource.resource_id) + }) @authorised_p(("group:resource:create-resource",), error_description="Insufficient privileges to create a resource", |