UPDATE metrics SET assoc_type = 1048585 WHERE assoc_type = 257
UPDATE metrics SET assoc_type = 531 WHERE assoc_type = 262
UPDATE metrics m, submissions s SET m.pkp_section_id = s.section_id WHERE m.submission_id IS NOT NULL AND s.submission_id = m.submission_id
UPDATE metrics m, submissions s SET m.pkp_section_id = s.section_id WHERE m.submission_id IS NOT NULL AND s.submission_id = m.submission_id
UPDATE metrics SET pkp_section_id = s.section_id FROM submissions s WHERE metrics.submission_id IS NOT NULL AND s.submission_id = metrics.submission_id
UPDATE metrics m, published_submissions p SET m.assoc_object_type = 259, m.assoc_object_id = p.issue_id WHERE m.submission_id IS NOT NULL AND p.submission_id = m.submission_id
UPDATE metrics m, published_submissions p SET m.assoc_object_type = 259, m.assoc_object_id = p.issue_id WHERE m.submission_id IS NOT NULL AND p.submission_id = m.submission_id
UPDATE metrics SET assoc_object_type = 259, assoc_object_id = p.issue_id FROM published_submissions p WHERE metrics.submission_id IS NOT NULL AND p.submission_id = metrics.submission_id
UPDATE metrics m, issue_galleys ig SET m.assoc_object_type = 259, m.assoc_object_id = ig.issue_id WHERE m.assoc_type = 261 AND ig.issue_id = m.assoc_id
UPDATE metrics m, issue_galleys ig SET m.assoc_object_type = 259, m.assoc_object_id = ig.issue_id WHERE m.assoc_type = 261 AND ig.issue_id = m.assoc_id
UPDATE metrics SET assoc_object_type = 259, assoc_object_id = ig.issue_id FROM issue_galleys ig WHERE metrics.assoc_type = 261 AND ig.issue_id = metrics.assoc_id
UPDATE metrics SET representation_id = assoc_id WHERE assoc_type = 521
UPDATE metrics m, submission_files sf SET m.representation_id = sf.assoc_id WHERE m.assoc_type = 515 AND sf.file_id = m.assoc_id AND sf.assoc_type = 521
UPDATE metrics m, submission_files sf SET m.representation_id = sf.assoc_id WHERE m.assoc_type = 515 AND sf.file_id = m.assoc_id AND sf.assoc_type = 521
UPDATE metrics SET representation_id = sf.assoc_id FROM submission_files sf WHERE metrics.assoc_type = 515 AND sf.file_id = metrics.assoc_id AND sf.assoc_type = 521
UPDATE metrics m, submission_galleys sg SET m.assoc_type = 515, m.assoc_id = sg.file_id WHERE m.assoc_type = 521 AND sg.galley_id = m.assoc_id AND ((sg.remote_url IS NULL) OR (sg.remote_url = ''))
UPDATE metrics m, submission_galleys sg SET m.assoc_type = 515, m.assoc_id = sg.file_id WHERE m.assoc_type = 521 AND sg.galley_id = m.assoc_id AND ((sg.remote_url IS NULL) OR (sg.remote_url = ''))
UPDATE metrics SET assoc_type = 515, assoc_id = sg.file_id FROM submission_galleys sg WHERE metrics.assoc_type = 521 AND sg.galley_id = metrics.assoc_id AND ((sg.remote_url IS NULL) OR (sg.remote_url = ''))