summaryrefslogtreecommitdiff
path: root/db/post_migrate/20201030203854_backfill_design_iids.rb
blob: 7acca6ad93db9f1a10fbab84b6f0ed0e85d430d0 (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
# frozen_string_literal: true

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

  DOWNTIME = false

  disable_ddl_transaction!

  class Designs < ActiveRecord::Base
    include EachBatch

    self.table_name = 'design_management_designs'
  end

  def up
    backfill = ::Gitlab::BackgroundMigration::BackfillDesignInternalIds.new(Designs)

    Designs.select(:project_id).distinct.each_batch(of: 100, column: :project_id) do |relation|
      backfill.perform(relation)
    end
  end

  def down
    # NOOP
  end
end