Add column type to labels and do the batch update in the same migration
This commit is contained in:
parent
7e11ca86fd
commit
9629bb962c
2 changed files with 6 additions and 18 deletions
|
@ -1,9 +1,14 @@
|
|||
class AddTypeToLabels < ActiveRecord::Migration
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
DOWNTIME = true
|
||||
DOWNTIME_REASON = 'Labels will not work as expected until this migration is complete.'
|
||||
|
||||
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
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
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
|
Loading…
Reference in a new issue