summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-10-03 18:43:39 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-10-19 14:58:25 -0200
commit9629bb962cd3666ac58cfbaba9d79df011221f41 (patch)
tree3a30996813e72ebf04b3d4fdb8fc8bc62181e0c6
parent7e11ca86fdb23c967c25b19735770f99f936b32c (diff)
downloadgitlab-ce-9629bb962cd3666ac58cfbaba9d79df011221f41.tar.gz
Add column type to labels and do the batch update in the same migration
-rw-r--r--db/migrate/20160919144305_add_type_to_labels.rb7
-rw-r--r--db/migrate/20160920191518_set_project_label_type_on_labels.rb17
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