From dbf924c57dc026747dae00141c1da67fbf856c80 Mon Sep 17 00:00:00 2001 From: Michael Kozono Date: Fri, 8 Sep 2017 13:09:52 -0700 Subject: Simplify query Performance does not need to be optimized in this case because this will be run in batches at a controlled rate. --- .../delete_conflicting_redirect_routes_range.rb | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'lib/gitlab') diff --git a/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb b/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb index a45fb6b6d0c..b1411be3016 100644 --- a/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb +++ b/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb @@ -28,25 +28,14 @@ module Gitlab <<~ROUTES_MATCH_REDIRECTS EXISTS ( SELECT 1 FROM routes - WHERE (#{route_paths_match_redirects}) + WHERE ( + LOWER(redirect_routes.path) = LOWER(routes.path) + OR LOWER(redirect_routes.path) LIKE LOWER(CONCAT(routes.path, '/%')) + ) AND routes.id BETWEEN #{start_id} AND #{end_id} ) ROUTES_MATCH_REDIRECTS end - - def route_paths_match_redirects - if Gitlab::Database.postgresql? - <<~ROUTE_PATHS_MATCH_REDIRECTS - LOWER(redirect_routes.path) = LOWER(routes.path) - OR LOWER(redirect_routes.path) LIKE LOWER(CONCAT(routes.path, '/%')) - ROUTE_PATHS_MATCH_REDIRECTS - else - <<~ROUTE_PATHS_MATCH_REDIRECTS - redirect_routes.path = routes.path - OR redirect_routes.path LIKE CONCAT(routes.path, '/%') - ROUTE_PATHS_MATCH_REDIRECTS - end - end end end end -- cgit v1.2.3