summaryrefslogtreecommitdiff
path: root/lib/gitlab/background_migration/populate_operation_visibility_permissions_from_operations.rb
blob: 46758bc8fedb7f4e5229d5f6ac5fa7d83118babf (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

module Gitlab
  module BackgroundMigration
    # Migrates the value operations_access_level to the new colums
    # monitor_access_level, deployments_access_level, infrastructure_access_level.
    # The operations_access_level setting is being split into three seperate toggles.
    class PopulateOperationVisibilityPermissionsFromOperations < BatchedMigrationJob
      operation_name :populate_operations_visibility
      feature_category :database

      def perform
        each_sub_batch do |batch|
          batch.update_all('monitor_access_level=operations_access_level,' \
            'infrastructure_access_level=operations_access_level,' \
            ' feature_flags_access_level=operations_access_level,'\
            ' environments_access_level=operations_access_level')
        end
      end

      private

      def mark_job_as_succeeded(*arguments)
        Gitlab::Database::BackgroundMigrationJob.mark_all_as_succeeded(
          'PopulateOperationVisibilityPermissionsFromOperations',
          arguments
        )
      end
    end
  end
end