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

20190924152703_migrate_issue_trackers_data.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 93ea501e7e0ba0c0238e0755e8f8928bc5cc8c8e (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
# frozen_string_literal: true

class MigrateIssueTrackersData < ActiveRecord::Migration[5.1]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false
  INTERVAL = 3.minutes.to_i
  BATCH_SIZE = 5_000
  MIGRATION = 'MigrateIssueTrackersSensitiveData'

  disable_ddl_transaction!

  class Service < ActiveRecord::Base
    self.table_name = 'services'
    self.inheritance_column = :_type_disabled

    include ::EachBatch
  end

  def up
    relation = Service.where(category: 'issue_tracker').where("properties IS NOT NULL AND properties != '{}' AND properties != ''")
    queue_background_migration_jobs_by_range_at_intervals(relation,
                                                          MIGRATION,
                                                          INTERVAL,
                                                          batch_size: BATCH_SIZE)
  end

  def down
    # no need
  end
end