HomePhabricator
Diffusion Comm 39ceae667aae

[keyserver] Add unique key on thread_name in the roles table

Description

[keyserver] Add unique key on thread_name in the roles table

Summary:
We want to ensure that for a given community, role names are unique (so we don't have several instances of one role with a different set of permissions). The key is a composite key between thread and name because we don't want to prevent the same role name from occurring across several different communities (i.e. 'Moderator' should be allowed in two different communities, but cannot exist twice in the same community).

This is the keyserver validation of preventing this error, the next step will involve adding some kind of client-side notice when they click 'Create' that it is a duplicate role name, before the call to create the role is made

Note: Given that the ability to create custom roles has begun in this stack, there shouldn't be an instance where there is a malformed DB state (except mine) with role names besides Admins and Members, so I don't see any issues coming out of this migration.

Part of ENG-4178.

Depends on D8431

Test Plan:
Confirmed that the migration was successful and tried to create a role with a duplicate name ('Members') and verified that an error throws

Reviewers: atul, ginsu, ashoat

Reviewed By: ashoat

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D8432

Details

Provenance
rohanAuthored on Jul 17 2023, 9:45 AM
Reviewer
ashoat
Differential Revision
D8432: [keyserver] Add unique key on thread_name in the roles table
Parents
rCOMMed836b9c759e: [native] Display loading indicator while role creation is in progress
Branches
Unknown
Tags
Unknown