MDL-42349 database activity:fix problem with references to deleted attachments and pictures