summaryrefslogtreecommitdiff
path: root/db/migrate/20200702201039_change_prometheus_metrics_identifier_index.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20200702201039_change_prometheus_metrics_identifier_index.rb')
-rw-r--r--db/migrate/20200702201039_change_prometheus_metrics_identifier_index.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/db/migrate/20200702201039_change_prometheus_metrics_identifier_index.rb b/db/migrate/20200702201039_change_prometheus_metrics_identifier_index.rb
new file mode 100644
index 00000000000..248195c8c75
--- /dev/null
+++ b/db/migrate/20200702201039_change_prometheus_metrics_identifier_index.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class ChangePrometheusMetricsIdentifierIndex < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ NEW_INDEX = :index_prometheus_metrics_on_identifier_and_null_project
+ OLD_INDEX = :index_prometheus_metrics_on_identifier
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :prometheus_metrics, :identifier, name: NEW_INDEX, unique: true, where: 'project_id IS NULL'
+ remove_concurrent_index_by_name :prometheus_metrics, OLD_INDEX
+ end
+
+ def down
+ add_concurrent_index :prometheus_metrics, :identifier, name: OLD_INDEX, unique: true
+ remove_concurrent_index_by_name :prometheus_metrics, NEW_INDEX
+ end
+end