Disable migrate_to_new_scheme once there is nothing to migrate.

Disable migrate_to_new_scheme once there is nothing to migrate.

diff --git a/app/models/upload.rb b/app/models/upload.rb
index 5c711a7..303f192 100644
--- a/app/models/upload.rb
+++ b/app/models/upload.rb
@@ -212,6 +212,12 @@ class Upload < ActiveRecord::Base
       scope = Upload.by_users.where("url NOT LIKE '%/original/_X/%' AND url LIKE '%/uploads/#{RailsMultisite::ConnectionManagement.current_db}%'").order(id: :desc)
 
       scope = scope.limit(limit) if limit
+
+      if scope.count == 0
+        SiteSetting.migrate_to_new_scheme = false
+        return problems
+      end
+
       remap_scope = nil
 
       scope.each do |upload|

GitHub sha: 573ddcbb

2 Likes

Revert "FEATURE: stop running migrate to new scheme once done"