I'm basically creating a new ticket for this JRA:
I believe the description was confusing, which lead us to believe that the problem was manually editing the database. In reality, this is a problem with deleting directories in JIRA's interface.
Steps to reproduce:
- Create a new LDAP directory in JIRA (delegated or not, reproducible in both)
- Synchronise this directory
- Verify that users/groups/memberships have been added to JIRA
- Check the database cwd_directory table. Notice the new directory and it's ID
- Back in JIRA's interface, disable/remove the new directory
- Now query the database again
- Notice that there is still data in cwd_user, cwd_user_attributes,cwd_group, cwd_membership referencing the deleted directory.
This causes no functionality loss within JIRA, but it will definitely clutter up the database. This is leaves invalid entries, making it harder to troubleshoot. This is especially a problem for admins testing new directory setups and have thousands of users.
On top of that, there really needs to be added are Foreign Key constraints to the tables.
For example, on the Confluence side there is this constraint: