From 882e54c78678bd4247d70fe5b04571543769bcee Mon Sep 17 00:00:00 2001
From: Jeong Arm <kjwonmail@gmail.com>
Date: Wed, 21 Sep 2022 06:50:19 +0900
Subject: [PATCH] Fix Ambiguous SQL error on tootctl media refresh (#19206)

---
 lib/mastodon/media_cli.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/mastodon/media_cli.rb b/lib/mastodon/media_cli.rb
index 4904cc5eb9..bba4a1bd72 100644
--- a/lib/mastodon/media_cli.rb
+++ b/lib/mastodon/media_cli.rb
@@ -234,7 +234,7 @@ module Mastodon
       end
 
       if options[:days].present?
-        scope = scope.where('id > ?', Mastodon::Snowflake.id_at(options[:days].days.ago, with_random: false))
+        scope = scope.where('media_attachments.id > ?', Mastodon::Snowflake.id_at(options[:days].days.ago, with_random: false))
       end
 
       processed, aggregate = parallelize_with_progress(scope) do |media_attachment|