...
In the result we see the id = 5. For future reference, this will be refered referred to as the domain_id
Try and delete the domain by executing the following query:
| Code Block | ||||
|---|---|---|---|---|
| ||||
delete from domain where name = 'spt.deepnetid.com' |
For future reference, this will be referred to as the first query
You will now see an error which should give details as to why the domain cannot be deleted... for example...
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
delete from role_domain where domain_id = 5 |
Hopefully you will see 1 row affected, which means that query has executed correctly and reference to the domain has been deleted from this table
Run the first query again.
This error tells us that a foreign key constraint fails where the domain_id is referenced in the table usergroup
| Code Block | ||||
|---|---|---|---|---|
| ||||
delete from usergroup where domain_id = 5 |
Unfortunately, that query returns the following error...
...because there is row in ldap_group that is referencing the id in a row of the usergroup table we need to delete. Therefor taht row in the ldap_group table needs to be deleted first.
| Expand | ||
|---|---|---|
| ||
The row where id = 7 in th ldap_group table needs to be deleted first, before the row with the same id on the usergroup table (which also references that domain_id) can be deleted. |
Only the usergroup table contains the column domain_id; therefore the only way to delete the related row in ldap_group is by matching it to where the domain_id = 5 in the usergroup table via a join query:
| Code Block | ||||
|---|---|---|---|---|
| ||||
DELETE lg FROM ldap_group lg JOIN usergroup ug ON lg.id = ug.id WHERE ug.domain_id = 5; |


