diff options
author | Felipe Artur <fcardozo@gitlab.com> | 2019-02-04 13:52:19 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-02-04 13:52:19 +0300 |
commit | d3f5fd33cfb0075d109494233ed7010f7e8db34d (patch) | |
tree | 7b26fbb9162ab6184a8145f45a8e723ea5d6de98 /db/post_migrate | |
parent | fa3a2f9e98e4bc2a1badf6fac41a002afab2a041 (diff) |
Fix template labels
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 |