diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-09-08 13:09:52 -0700 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-09-14 14:17:23 -0700 |
commit | dbf924c57dc026747dae00141c1da67fbf856c80 (patch) | |
tree | 3e315d37b119498f6775b2a2079f7c19f5d47b23 | |
parent | f1e963bd89e737868a3a49358d714a288738c2e8 (diff) | |
download | gitlab-ce-dbf924c57dc026747dae00141c1da67fbf856c80.tar.gz |
Simplify query
Performance does not need to be optimized in this case because this will be run in batches at a controlled rate.
-rw-r--r-- | lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb | 19 |
1 files changed, 4 insertions, 15 deletions
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 |