FortiSIEM
FortiSIEM provides Security Information and Event Management (SIEM) and User and Entity Behavior Analytics (UEBA)
kdave
Staff
Staff
Article Id 371543
Description This article describes a way to resolve ERROR: ((id))=(value) is still referenced from table 'ph_group_item' while deleting Organization from GUI.
Scope FortiSIEM.
Solution

It has been often observed while trying to remove Organization from GUI from Admin -> Setup -> Organization, the following error occurs and Organization cannot be deleted from GUI:

 

Please make sure the following items in this org/collector are not needed and try removing them first.


Root cause: ERROR: update or delete on table "ph_group" violates foreign key constraint "ph_group_item2group_fk" on table "ph_group_item"
Detail: Key (id)=(4646034439) is still referenced from table "ph_group_item".

 

Org delete error.jpg

 

The following workaround can be implemented to remove reference to entries in the database for specific organizations.

 

psql -U phoenix phoenixdb

 

Check which entries are causing this issue.

 

select * from ph_group_item where group_id='<ID>';

 

select * from ph_group where id='<ID>';

 

Replace ID as observed from the above error, for example:

 

select * from ph_group_item where group_id='4646034439';

select * from ph_group where id='4646034439';

 

Check if ph_group_item table contains entries with reference group_id:

 

update ph_group_item set group_id=NULL where group_id='<ID>';

 

Replace <ID> with actual ID:

 

update ph_group_item set group_id=NULL where group_id='4646034439';

 

Then, try removing Organization again from GUI.

 

If the same error occurs with any other group ID, it would need to be removed using the above steps.