summaryrefslogtreecommitdiff
path: root/db/migrate/20190910114843_exclude_nulls_from_index_on_namespaces_type.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20190910114843_exclude_nulls_from_index_on_namespaces_type.rb')
-rw-r--r--db/migrate/20190910114843_exclude_nulls_from_index_on_namespaces_type.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/db/migrate/20190910114843_exclude_nulls_from_index_on_namespaces_type.rb b/db/migrate/20190910114843_exclude_nulls_from_index_on_namespaces_type.rb
new file mode 100644
index 00000000000..8237c48b16d
--- /dev/null
+++ b/db/migrate/20190910114843_exclude_nulls_from_index_on_namespaces_type.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class ExcludeNullsFromIndexOnNamespacesType < ActiveRecord::Migration[5.1]
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(:namespaces, :type, where: 'type is not null', name: 'index_namespaces_on_type_partial')
+ remove_concurrent_index_by_name(:namespaces, 'index_namespaces_on_type')
+ end
+
+ def down
+ add_concurrent_index(:namespaces, :type, name: 'index_namespaces_on_type')
+ remove_concurrent_index_by_name(:namespaces, 'index_namespaces_on_type_partial')
+ end
+end