From 5d64b590bfaa56387a51b7350364bb5627e1711b Mon Sep 17 00:00:00 2001 From: Drew Blessing Date: Thu, 20 Oct 2016 11:52:38 -0500 Subject: [PATCH] Fix conflicts --- CHANGELOG-EE.md | 2 ++ .../20160725210010_remove_orphaned_approvers.rb | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 db/migrate/20160725210010_remove_orphaned_approvers.rb diff --git a/CHANGELOG-EE.md b/CHANGELOG-EE.md index e4bdb45b99d46a..e5b5dc48bbe201 100644 --- a/CHANGELOG-EE.md +++ b/CHANGELOG-EE.md @@ -167,6 +167,8 @@ Please view this file on the master branch, on stable branches it's out of date. - Fix broken `user_allowed?` check in Git Annex push. !597 ## 8.10.1 +v 8.10.2 (unreleased) + - Remove orphaned merge request approvers from the database - No EE-specific changes diff --git a/db/migrate/20160725210010_remove_orphaned_approvers.rb b/db/migrate/20160725210010_remove_orphaned_approvers.rb new file mode 100644 index 00000000000000..19a8636fdbf9c8 --- /dev/null +++ b/db/migrate/20160725210010_remove_orphaned_approvers.rb @@ -0,0 +1,16 @@ +# Migration type: online without errors (works on previous version and new one) +class RemoveOrphanedApprovers < ActiveRecord::Migration + + # In older versions of GitLab there wasn't a dependent destroy on merge + # approvers. This resulted in some orphaned data. See + # https://gitlab.com/gitlab-org/gitlab-ee/issues/1 + def up + # Add secondary args for the MySQL which doesn't have sane defaults like PostgreSQL adapter + until exec_delete('DELETE FROM approvers WHERE id IN (SELECT approvers.id FROM approvers LEFT JOIN users ON users.id=approvers.user_id WHERE users.id IS NULL LIMIT 1000)', 'SQL', []) == 0 + end + end + + def down + # There's no reason to go back. + end +end -- GitLab