summaryrefslogtreecommitdiff
path: root/db/post_migrate/20220412143552_consume_remaining_encrypt_integration_property_jobs.rb
blob: 69850b3a32f970ccf28ed8bea01f6a4b6eb50df4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

class ConsumeRemainingEncryptIntegrationPropertyJobs < Gitlab::Database::Migration[1.0]
  disable_ddl_transaction!

  BATCH_SIZE = 50

  def up
    Gitlab::BackgroundMigration.steal('EncryptIntegrationProperties')

    model = define_batchable_model('integrations')
    relation = model.where.not(properties: nil).where(encrypted_properties: nil)

    relation.each_batch(of: BATCH_SIZE) do |batch|
      range = batch.pluck('MIN(id)', 'MAX(id)').first

      Gitlab::BackgroundMigration::EncryptIntegrationProperties.new.perform(*range)
    end
  end

  def down
  end
end