diff options
author | Felipe Artur <fcardozo@gitlab.com> | 2019-02-04 10:52:19 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-02-04 10:52:19 +0000 |
commit | d3f5fd33cfb0075d109494233ed7010f7e8db34d (patch) | |
tree | 7b26fbb9162ab6184a8145f45a8e723ea5d6de98 /db | |
parent | fa3a2f9e98e4bc2a1badf6fac41a002afab2a041 (diff) | |
download | gitlab-ce-d3f5fd33cfb0075d109494233ed7010f7e8db34d.tar.gz |
Fix template labels
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20190131122559_fix_null_type_labels.rb | 23 | ||||
-rw-r--r-- | db/schema.rb | 2 |
2 files changed, 24 insertions, 1 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 diff --git a/db/schema.rb b/db/schema.rb index 7c1733becb9..4cc870ba6c8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20190124200344) do +ActiveRecord::Schema.define(version: 20190131122559) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" |