summaryrefslogtreecommitdiff
path: root/db/migrate/20210324112439_add_index_mirror_data_on_retry_next_execution_where_status.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20210324112439_add_index_mirror_data_on_retry_next_execution_where_status.rb')
-rw-r--r--db/migrate/20210324112439_add_index_mirror_data_on_retry_next_execution_where_status.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/db/migrate/20210324112439_add_index_mirror_data_on_retry_next_execution_where_status.rb b/db/migrate/20210324112439_add_index_mirror_data_on_retry_next_execution_where_status.rb
new file mode 100644
index 00000000000..68ce5363b70
--- /dev/null
+++ b/db/migrate/20210324112439_add_index_mirror_data_on_retry_next_execution_where_status.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddIndexMirrorDataOnRetryNextExecutionWhereStatus < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ INDEX_NAME = 'index_mirror_data_non_scheduled_or_started'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :project_mirror_data,
+ [:next_execution_timestamp, :retry_count],
+ where: "(status)::text <> ALL ('{scheduled,started}'::text[])",
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index :project_mirror_data,
+ [:next_execution_timestamp, :retry_count],
+ where: "(status)::text <> ALL ('{scheduled,started}'::text[])",
+ name: INDEX_NAME
+ end
+end