summaryrefslogtreecommitdiff
path: root/db/migrate/20160919144305_add_type_to_labels.rb
blob: f028c9460d1de2c76e7f7f9b0a4beb0b280ab4a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class AddTypeToLabels < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = true
  DOWNTIME_REASON = 'Labels will not work as expected until this migration is complete.'.freeze

  def change
    add_column :labels, :type, :string

    update_column_in_batches(:labels, :type, 'ProjectLabel') do |table, query|
      query.where(table[:project_id].not_eq(nil))
    end
  end
end