Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20210119122354_alter_vsa_issue_first_mentioned_in_commit_value.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 132d72e180bbf4c42df4c8c9bc62cd2d70e76539 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

class AlterVsaIssueFirstMentionedInCommitValue < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  ISSUE_FIRST_MENTIONED_IN_COMMIT_FOSS = 2
  ISSUE_FIRST_MENTIONED_IN_COMMIT_EE = 6

  class GroupStage < ActiveRecord::Base
    self.table_name = 'analytics_cycle_analytics_group_stages'

    include EachBatch
  end

  def up
    GroupStage.each_batch(of: 100) do |relation|
      relation
        .where(start_event_identifier: ISSUE_FIRST_MENTIONED_IN_COMMIT_EE)
        .update_all(start_event_identifier: ISSUE_FIRST_MENTIONED_IN_COMMIT_FOSS)

      relation
        .where(end_event_identifier: ISSUE_FIRST_MENTIONED_IN_COMMIT_EE)
        .update_all(end_event_identifier: ISSUE_FIRST_MENTIONED_IN_COMMIT_FOSS)
    end
  end

  def down
    # rollback is not needed, the identifier "6" is the same as identifier "2" on the application level
  end
end