diff options
author | Alexandru Croitor <acroitor@gitlab.com> | 2019-09-11 15:17:51 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-09-11 15:17:51 +0300 |
commit | b012174d6fb5dcef10db1dc67754bb5c59aa2a07 (patch) | |
tree | 48fd9320ab6c018d7aac6828a4547244d0682b2e /lib/gitlab | |
parent | e4b28b42c3b125a7836eaabf77c2fe6df4639429 (diff) |
Change discussion_ids on promoted epics notes
Notes on epics promoted from an issue used to get same discussion_id
as the notes from the issue the epic was promoted from, which would
cause problems when trying to reply to the epic discussion.
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/background_migration/fix_promoted_epics_discussion_ids.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/gitlab/background_migration/fix_promoted_epics_discussion_ids.rb b/lib/gitlab/background_migration/fix_promoted_epics_discussion_ids.rb new file mode 100644 index 00000000000..1a80ccdee92 --- /dev/null +++ b/lib/gitlab/background_migration/fix_promoted_epics_discussion_ids.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # This migration updates discussion ids for epics that were promoted from issue so that the discussion id on epics + # is different from discussion id on issue, which was causing problems when replying to epic discussions as it would + # identify the discussion as related to an issue and complaint about missing project_id + class FixPromotedEpicsDiscussionIds + # notes model to iterate through the notes to be updated + class Note < ActiveRecord::Base + self.table_name = 'notes' + self.inheritance_column = :_type_disabled + end + + def perform(discussion_ids) + Note.where(noteable_type: 'Epic') + .where(discussion_id: discussion_ids) + .update_all("discussion_id=MD5(discussion_id)||substring(discussion_id from 1 for 8)") + end + end + end +end |