summaryrefslogtreecommitdiff
path: root/db/post_migrate/20180430143705_backfill_runner_type_for_ci_runners_post_migrate.rb
blob: 0e6ec46e5f07a5549b4977d3bd861c7461298dc8 (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
class BackfillRunnerTypeForCiRunnersPostMigrate < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  INSTANCE_RUNNER_TYPE = 1
  PROJECT_RUNNER_TYPE = 3

  disable_ddl_transaction!

  def up
    # rubocop:disable Migration/UpdateColumnInBatches
    update_column_in_batches(:ci_runners, :runner_type, INSTANCE_RUNNER_TYPE) do |table, query|
      query.where(table[:is_shared].eq(true)).where(table[:runner_type].eq(nil))
    end

    update_column_in_batches(:ci_runners, :runner_type, PROJECT_RUNNER_TYPE) do |table, query|
      query.where(table[:is_shared].eq(false)).where(table[:runner_type].eq(nil))
    end
  end

  def down
  end
end