REFACTOR: create custom field even when missing post uploads not found

REFACTOR: create custom field even when missing post uploads not found

diff --git a/app/jobs/scheduled/ensure_post_uploads_existence.rb b/app/jobs/scheduled/ensure_post_uploads_existence.rb
index 327bddd..cc3434a 100644
--- a/app/jobs/scheduled/ensure_post_uploads_existence.rb
+++ b/app/jobs/scheduled/ensure_post_uploads_existence.rb
@@ -14,7 +14,7 @@ module Jobs
         .destroy_all
 
       Post
-        .joins("LEFT JOIN post_custom_fields cf ON posts.id = cf.post_id AND cf.name = 'missing_uploads'")
+        .joins("LEFT JOIN post_custom_fields cf ON posts.id = cf.post_id AND cf.name = '#{MISSING_UPLOADS}'")
         .where("(posts.cooked LIKE '%<a %' OR posts.cooked LIKE '%<img %') AND cf.id IS NULL")
         .find_in_batches(batch_size: 100) do |posts|
 
@@ -34,11 +34,9 @@ module Jobs
           end
 
           if missing.present?
-            post.preloaded_custom_fields = nil
-            post.custom_fields[MISSING_UPLOADS] = missing
-            post.save_custom_fields
-          elsif post.custom_fields[MISSING_UPLOADS].present?
-            PostCustomField.find_by(post_id: post.id, name: MISSING_UPLOADS).destroy!
+            missing.each { |src| PostCustomField.create!(post_id: post.id, name: MISSING_UPLOADS, value: src) }
+          else
+            PostCustomField.create!(post_id: post.id, name: MISSING_UPLOADS, value: nil)
           end
         end
       end

GitHub sha: a385f6c4