diff options
author | Michael Kozono <mkozono@gmail.com> | 2018-01-03 12:03:52 -0800 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2018-01-03 12:23:20 -0800 |
commit | f635277228c4ac90bd7215db741392df1998ddfc (patch) | |
tree | f1cbbc562a43da678c41984f7bd1c88a0a12883c /lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb | |
parent | ea55445dad4e11a16ab6eec58c85198870bd1f40 (diff) | |
download | gitlab-ce-f635277228c4ac90bd7215db741392df1998ddfc.tar.gz |
Make DeleteConflictingRedirectRoutes no-opmk-no-op-delete-conflicting-redirects
Both the post-deploy and background migration.
Diffstat (limited to 'lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb')
-rw-r--r-- | lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb | 36 |
1 files changed, 2 insertions, 34 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 a1af045a71f..21b626dde56 100644 --- a/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb +++ b/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb @@ -1,44 +1,12 @@ # frozen_string_literal: true -# rubocop:disable Metrics/LineLength # rubocop:disable Style/Documentation module Gitlab module BackgroundMigration class DeleteConflictingRedirectRoutesRange - class Route < ActiveRecord::Base - self.table_name = 'routes' - end - - class RedirectRoute < ActiveRecord::Base - self.table_name = 'redirect_routes' - end - - # start_id - The start ID of the range of events to process - # end_id - The end ID of the range to process. def perform(start_id, end_id) - return unless migrate? - - conflicts = RedirectRoute.where(routes_match_redirects_clause(start_id, end_id)) - num_rows = conflicts.delete_all - - Rails.logger.info("Gitlab::BackgroundMigration::DeleteConflictingRedirectRoutesRange [#{start_id}, #{end_id}] - Deleted #{num_rows} redirect routes that were conflicting with routes.") - end - - def migrate? - Route.table_exists? && RedirectRoute.table_exists? - end - - def routes_match_redirects_clause(start_id, end_id) - <<~ROUTES_MATCH_REDIRECTS - EXISTS ( - SELECT 1 FROM routes - 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 + # No-op. + # See https://gitlab.com/gitlab-com/infrastructure/issues/3460#note_53223252 end end end |