diff options
Diffstat (limited to 'db/post_migrate/20220720090354_remove_pending_builds_covering_index_from_ci_builds.rb')
-rw-r--r-- | db/post_migrate/20220720090354_remove_pending_builds_covering_index_from_ci_builds.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/db/post_migrate/20220720090354_remove_pending_builds_covering_index_from_ci_builds.rb b/db/post_migrate/20220720090354_remove_pending_builds_covering_index_from_ci_builds.rb new file mode 100644 index 00000000000..fb3d12840cc --- /dev/null +++ b/db/post_migrate/20220720090354_remove_pending_builds_covering_index_from_ci_builds.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class RemovePendingBuildsCoveringIndexFromCiBuilds < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + INDEX_NAME = 'index_ci_builds_runner_id_pending_covering' + + def up + remove_concurrent_index_by_name :ci_builds, INDEX_NAME + end + + # rubocop:disable Migration/PreventIndexCreation + def down + disable_statement_timeout do + unless index_exists_by_name?(:ci_builds, INDEX_NAME) + execute <<~SQL.squish + CREATE INDEX CONCURRENTLY #{INDEX_NAME} + ON ci_builds (runner_id, id) + INCLUDE (project_id) + WHERE status = 'pending' AND type = 'Ci::Build' + SQL + end + end + end + # rubocop:enable Migration/PreventIndexCreation +end |