summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20190131122559_fix_null_type_labels.rb23
-rw-r--r--db/schema.rb2
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"