@jnugent Hello we found the solution, we ran the commands below and solved it, thanks for the support, we can close this ticket.
SELECT sf.submission_file_id FROM submission_files sf LEFT JOIN notes n ON (sf.assoc_id = n.note_id) WHERE sf.assoc_type = 520 AND n.note_id IS NULL;
DELETE FROM submission_file_revisions WHERE submission_file_id IN (SELECT sf.submission_file_id FROM submission_files sf LEFT JOIN notes n ON (sf.assoc_id = n.note_id) WHERE sf.assoc_type = 520 AND n.note_id IS NULL);
delete from submission_files where submission_file_id in (
SELECT sfid FROM (SELECT sf.submission_file_id AS sfid FROM submission_files sf
LEFT JOIN notes n ON (sf.assoc_id = n.note_id) WHERE sf.assoc_type = 520 AND n.note_id IS NULL) AS c);