How to rename a group and preserve its permissions
An administrator may need to rename a Confluence group to reflect changes their organisation undergoes. This is currently not possible to do in Confluence, but a feature request is under consideration: - CONFSERVER-9159Getting issue details... STATUS
However, we can manually change a group name and all the permissions related to it through the database.
Bear in mind that such procedure is not part of Confluence's intended functionality. As such, this process is not covered under the Atlassian Support Offerings and the information given here is provided as-is. It should be thoroughly tested in a development or staging environment before implementing any changes in your production instance.
1. Identify the permissions granted to the target group
As noted in Confluence permissions architecture, Confluence recognizes permissions at site level and at space level, as well as page-level restrictions. Therefore, we must identify where our target group is being used before editing the group.
Run the following SQL queries against the Confluence database, replacing <group_name> with the group name, in lowercase:
SELECT permgroupname AS groupname, permtype AS "permission_type (global)" FROM spacepermissions WHERE spaceid IS NULL AND permgroupname in ('<group_name>') ORDER BY permgroupname, permtype;
SELECT permgroupname AS groupname, s.spacename, permtype AS "permission_type (space)" FROM spacepermissions sp JOIN spaces s ON sp.spaceid = s.spaceid WHERE permgroupname in ('<group_name>') ORDER BY permgroupname, s.spacename, permtype;
SELECT cp.groupname, content.title AS content_title, cp.cp_type AS "permission_type (page)" FROM content_perm cp JOIN content_perm_set cps ON cp.cps_id = cps.id JOIN content ON content.contentid = cps.content_id WHERE cp.groupname in ('<group_name>') ORDER BY cp.groupname, content.title, cp.cp_type;
2. Edit the permissions, depending on the permission level
For example, we may want to preserve only page-level restrictions, or our target group only has Global permissions to be adjusted.
Run the following queries depending on the situation:
UPDATE spacepermissions SET permgroupname = 'NEW_GROUP_NAME' WHERE permgroupname IN ('OLD_GROUP_NAME') AND spaceid IS NULL;
UPDATE spacepermissions SET permgroupname = 'NEW_GROUP_NAME' WHERE permgroupname IN ('OLD_GROUP_NAME') AND spaceid IS NOT NULL;
UPDATE spacepermissions SET permgroupname = 'NEW_GROUP_NAME' WHERE permgroupname IN ('OLD_GROUP_NAME') AND spaceid IN (SELECT spaceid FROM spaces WHERE spacename IN ('<SPACE_NAME_1>', '<SPACE_NAME_2>', '<SPACE_NAME_n>'));
UPDATE content_perm SET groupname = 'NEW_GROUP_NAME' WHERE groupname IN ('OLD_GROUP_NAME');
3. Rename the Group
If you are going to link Confluence to a different Directory and would like to transfer the permissions from group A (current) to group B (synced from the new directory), you can skip this step.
UPDATE cwd_group SET group_name = 'NEW_GROUP_NAME', lower_group_name = 'NEW_GROUP_NAME' WHERE group_name = 'OLD_GROUP_NAME';
Otherwise, update the group in the external directory that hosts the target group. e.g. JIRA or Active Directory.
4 Restart Confluence and flush caches
After adjusting the database, restart Confluence and clear Confluence's internal caches at General Configuration > Cache Management > Flush All (at the bottom).