FIX: Don't count ignored, missing uploads in migration to S3

This commit is contained in:
Gerhard Schlager 2020-02-12 16:18:15 +01:00
parent fb2fad4811
commit 0adab26e45
1 changed files with 14 additions and 2 deletions

View File

@ -84,8 +84,20 @@ module FileStore
end
Discourse::Application.load_tasks
Rake::Task['posts:missing_uploads'].invoke('single_site')
count = PostCustomField.where(name: Post::MISSING_UPLOADS).count
Rake::Task['posts:missing_uploads']
count = DB.query_single(<<~SQL, Post::MISSING_UPLOADS, Post::MISSING_UPLOADS_IGNORED).first
SELECT COUNT(1)
FROM posts p
WHERE EXISTS (
SELECT 1
FROM post_custom_fields f
WHERE f.post_id = p.id AND f.name = ?
) AND NOT EXISTS (
SELECT 1
FROM post_custom_fields f
WHERE f.post_id = p.id AND f.name = ?
)
SQL
if count > 0
error_message = "rake posts:missing_uploads identified #{count} issues. #{failure_message}"
raise_or_log(error_message, should_raise)