summaryrefslogtreecommitdiff
path: root/db/migrate/20200402115623_add_index_on_successful_deployment_and_environment_id_to_deployments.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20200402115623_add_index_on_successful_deployment_and_environment_id_to_deployments.rb')
-rw-r--r--db/migrate/20200402115623_add_index_on_successful_deployment_and_environment_id_to_deployments.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/db/migrate/20200402115623_add_index_on_successful_deployment_and_environment_id_to_deployments.rb b/db/migrate/20200402115623_add_index_on_successful_deployment_and_environment_id_to_deployments.rb
new file mode 100644
index 00000000000..c86f7ad63f0
--- /dev/null
+++ b/db/migrate/20200402115623_add_index_on_successful_deployment_and_environment_id_to_deployments.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexOnSuccessfulDeploymentAndEnvironmentIdToDeployments < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_successful_deployments_on_cluster_id_and_environment_id'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :deployments, [:cluster_id, :environment_id], where: 'status = 2', name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index :deployments, [:cluster_id, :environment_id], where: 'status = 2', name: INDEX_NAME
+ end
+end