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

20230522220709_ensure_incident_work_item_type_backfill_is_finished.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a93f5417dd02d1ea2552050038fa842be6339195 (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
35
36
37
# frozen_string_literal: true

class EnsureIncidentWorkItemTypeBackfillIsFinished < Gitlab::Database::Migration[2.1]
  disable_ddl_transaction!

  restrict_gitlab_migration gitlab_schema: :gitlab_main

  MIGRATION = 'BackfillWorkItemTypeIdForIssues'
  INCIDENT_ENUM_TYPE = 1

  class MigrationWorkItemType < MigrationRecord
    self.table_name = 'work_item_types'
  end

  def up
    incident_work_item_type = MigrationWorkItemType.find_by(namespace_id: nil, base_type: INCIDENT_ENUM_TYPE)

    if incident_work_item_type.blank?
      say(
        'Incident work item type not found. Make sure the work_item_types table is populated' \
        'before running this migration'
      )
      return
    end

    ensure_batched_background_migration_is_finished(
      job_class_name: MIGRATION,
      table_name: :issues,
      column_name: :id,
      job_arguments: [INCIDENT_ENUM_TYPE, incident_work_item_type.id]
    )
  end

  def down
    # no-op
  end
end