summaryrefslogtreecommitdiff
path: root/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/post_migrate/20170815060945_remove_duplicate_mr_events.rb')
-rw-r--r--db/post_migrate/20170815060945_remove_duplicate_mr_events.rb26
1 files changed, 0 insertions, 26 deletions
diff --git a/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb b/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb
deleted file mode 100644
index fdc126b8fd6..00000000000
--- a/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-# See http://doc.gitlab.com/ce/development/migration_style_guide.html
-# for more information on how to write migrations for GitLab.
-
-class RemoveDuplicateMrEvents < ActiveRecord::Migration[4.2]
- include Gitlab::Database::MigrationHelpers
- DOWNTIME = false
-
- class Event < ActiveRecord::Base
- self.table_name = 'events'
- end
-
- def up
- base_condition = "action = 1 AND target_type = 'MergeRequest' AND created_at > '2017-08-13'"
- Event.select('target_id, count(*)')
- .where(base_condition)
- .group('target_id').having('count(*) > 1').each do |event|
- duplicates = Event.where("#{base_condition} AND target_id = #{event.target_id}").pluck(:id)
- duplicates.shift
-
- Event.where(id: duplicates).delete_all
- end
- end
-
- def down
- end
-end