I'm using Api4 to remove a Custom Group upon uninstalling an extension. The api call looks like
\Civi\Api4\CustomGroup::delete() ->addWhere('id', '=', $idOfCustomGroup) ->execute();
The Custom Group and all of its fields were deleted, as expected. The civicrm_value_... table, which stores the values of the fields, were not deleted.
I replaced the api4 call with an api3 call as follows, and it deletes the Custom Group, all fields, and the values table:
civicrm_api3('CustomGroup', 'delete', [ 'id' => $id, ]);
Is this a bug in api4? I think the behavior should be consistent, and that the preferred behavior should be to delete the values table when deleting a Custom Group, because if I wanted to keep the values I would disable the Group instead of deleting it. As well, not deleting the values table interferes with reinstalling the extension when it is installed from an xml file (as described in the developer manual: https://docs.civicrm.org/dev/en/latest/extensions/civix/#add-custom-fields)