diff options
Diffstat (limited to 'db/post_migrate')
-rw-r--r-- | db/post_migrate/20190131122559_fix_null_type_labels.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/db/post_migrate/20190131122559_fix_null_type_labels.rb b/db/post_migrate/20190131122559_fix_null_type_labels.rb new file mode 100644 index 00000000000..83bb613990c --- /dev/null +++ b/db/post_migrate/20190131122559_fix_null_type_labels.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class FixNullTypeLabels < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + update_column_in_batches(:labels, :type, 'ProjectLabel') do |table, query| + query.where( + table[:project_id].not_eq(nil) + .and(table[:template].eq(false)) + .and(table[:type].eq(nil)) + ) + end + end + + def down + # no action + end +end |