summaryrefslogtreecommitdiff
path: root/db/migrate/20161202152031_remove_duplicates_from_routes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20161202152031_remove_duplicates_from_routes.rb')
-rw-r--r--db/migrate/20161202152031_remove_duplicates_from_routes.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/db/migrate/20161202152031_remove_duplicates_from_routes.rb b/db/migrate/20161202152031_remove_duplicates_from_routes.rb
index 510796e05f2..a21bde69995 100644
--- a/db/migrate/20161202152031_remove_duplicates_from_routes.rb
+++ b/db/migrate/20161202152031_remove_duplicates_from_routes.rb
@@ -7,6 +7,11 @@ class RemoveDuplicatesFromRoutes < ActiveRecord::Migration
DOWNTIME = false
def up
+ # We can skip this migration when running a PostgreSQL database because
+ # we use an optimized query in the "FillProjectsRoutesTable" migration
+ # to fill these values that avoid duplicate entries in the routes table.
+ return unless Gitlab::Database.mysql?
+
select_all("SELECT path FROM #{quote_table_name(:routes)} GROUP BY path HAVING COUNT(*) > 1").each do |row|
path = connection.quote(row['path'])
execute(%Q{