How to change role name?

Is there a way to change a role name? If not, is there a quick way of copying a role and giving the copy a new name? Or any other workaround? I’m even willing to do some sql queries if that will work.

Why don’t you just create a new role and delete the old one?

Because that requires me to manually click every single privilege, either from memory (impossible), or by having two tabs visible on my screen at the same time. It’s a terrible UX, and since the entire UX of privileges is already terrible, it would be nice if simply renaming a role was easy. I understand there may be database issues in renaming it, fine, let me duplicate a role and give the duplicate a new name. I can probably do that in mysql, and if that’s the solution, so be it, but it would be FAR faster than manually re-creating a role.

In your database, disable foreign key checks with: SET FOREIGN_KEY_CHECKS=0

Then change the role name in the role table.

Update the corresponding roles in the user_role table.

Finally turn back the foreign key constraint enforcement with: SET FOREIGN_KEY_CHECKS=1

I was just looking into this same question. Adding to Daniel’s steps, I think the change of the role name has to be done on the following tables.columns.

  • role.role
  • user_role.role
  • role_role.parent_role
  • role_role.child_role
  • role_privilege.role