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 | |
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')
-rw-r--r-- | db/migrate/20160919144305_add_type_to_labels.rb | 7 | ||||
-rw-r--r-- | db/migrate/20160920191518_set_project_label_type_on_labels.rb | 17 |
2 files changed, 6 insertions, 18 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 diff --git a/db/migrate/20160920191518_set_project_label_type_on_labels.rb b/db/migrate/20160920191518_set_project_label_type_on_labels.rb deleted file mode 100644 index af47d0320e2..00000000000 --- a/db/migrate/20160920191518_set_project_label_type_on_labels.rb +++ /dev/null @@ -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 |