Às vezes, uso o script do explorador para encontrar uploads grandes.
Quando tento executar a consulta
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
Recebo uma mensagem:
PG::UndefinedTable: ERROR: relation "post_uploads" does not exist
LINE 13: FROM post_uploads
^
Sim. A tabela post_uploads foi descontinuada. Acho que agora precisa usar as tabelas uploads e upload_references?
Obrigado pelo relatório.
Acho que esta é a versão atualizada, caso precise, @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