diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-03 18:43:39 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-19 14:58:25 -0200 |
commit | 9629bb962cd3666ac58cfbaba9d79df011221f41 (patch) | |
tree | 3a30996813e72ebf04b3d4fdb8fc8bc62181e0c6 /db/migrate/20160919144305_add_type_to_labels.rb | |
parent | 7e11ca86fdb23c967c25b19735770f99f936b32c (diff) | |
download | gitlab-ce-9629bb962cd3666ac58cfbaba9d79df011221f41.tar.gz |
Add column type to labels and do the batch update in the same migration
Diffstat (limited to 'db/migrate/20160919144305_add_type_to_labels.rb')
-rw-r--r-- | db/migrate/20160919144305_add_type_to_labels.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/db/migrate/20160919144305_add_type_to_labels.rb b/db/migrate/20160919144305_add_type_to_labels.rb index 43aac7846d3..66172bda6ff 100644 --- a/db/migrate/20160919144305_add_type_to_labels.rb +++ b/db/migrate/20160919144305_add_type_to_labels.rb @@ -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 |