Sometimes I use explorer script to find large uploads.
When I try to run the query
SELECT posts.id AS post_id,
uploads.original_filename,
ROUND(uploads.filesize / 1000000.0, 2) AS size_in_mb,
uploads.extension,
uploads.created_at,
uploads.url
FROM post_uploads
JOIN uploads ON uploads.id = post_uploads.upload_id
JOIN posts ON posts.id = post_uploads.post_id
ORDER BY uploads.filesize DESC
LIMIT 50
I get a message:
PG::UndefinedTable: ERROR: relation "post_uploads" does not exist
LINE 13: FROM post_uploads
^
Ah yes. The post_uploads table has been deprecated. I think it needs to use the uploads and upload_references tables now?
Thanks for the report.
I think this is the updated version if you need it @Ivan_Rapekas:
SELECT posts.id AS post_id,
uploads.original_filename,
ROUND(uploads.filesize / 1000000.0, 2) AS size_in_mb,
uploads.extension,
uploads.created_at,
uploads.url
FROM upload_references
JOIN uploads ON uploads.id = upload_references.upload_id
JOIN posts ON posts.id = upload_references.target_id AND upload_references.target_type = 'Post'
ORDER BY uploads.filesize DESC
LIMIT 50