[copied from https://issues.civicrm.org/jira/browse/CRM-20711 noted on CiviCRM version 4.7.27]

In the Contact record, when I try to remove or delete a contact from a group they've already been added to, I receive this error:

DB Constraint Violation - group_id should possibly be marked as mandatory for GroupContact,get API. If so, please raise a bug report.

I am able to remove a contact from a group when in the Group's list of contacts view, so this isn't critical. Posting in case it happens for others.


This bug seems to occur on old (i.e. version 2.x) installations, due to an error in an old upgrade script that removed the location_id field from the civicrm_group_contact table.

You can fix it using this sql:

ALTER TABLE civicrm_group_contact ADD COLUMN `location_id` int(10) unsigned DEFAULT NULL COMMENT 'Optional location to associate with this membership'

Credit for the solution goes to Eileen, via this commit:


Credit for the original issue linked in the question above goes to Lizz Trudeau.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.