summaryrefslogtreecommitdiff
path: root/db/post_migrate/20190131122559_fix_null_type_labels.rb
blob: 83bb613990c54f461f51979e5a86da46b08ca050 (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 FixNullTypeLabels < ActiveRecord::Migration[5.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    update_column_in_batches(:labels, :type, 'ProjectLabel') do |table, query|
      query.where(
        table[:project_id].not_eq(nil)
          .and(table[:template].eq(false))
          .and(table[:type].eq(nil))
      )
    end
  end

  def down
    # no action
  end
end