20160919144305_add_type_to_labels.rb 485 Bytes
Newer Older
1
# rubocop:disable Migration/UpdateColumnInBatches
2
class AddTypeToLabels < ActiveRecord::Migration[4.2]
3 4
  include Gitlab::Database::MigrationHelpers

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

8 9
  disable_ddl_transaction!

10 11
  def change
    add_column :labels, :type, :string
12 13 14 15

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