Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20160920191518_set_project_label_type_on_labels.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: af47d0320e231d677c5751d1ea9076a97d8cf85d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class SetProjectLabelTypeOnLabels < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

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

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