diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-17 21:11:29 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-17 21:11:29 +0000 |
commit | a0b4a462b0c6f333651ae9e0c0ca1e5794e7b4e1 (patch) | |
tree | 37dce5303162eaf08841616347de9f65ba8dabf7 /db/post_migrate/20210311093723_add_partial_index_on_ci_pipelines_by_cancelable_status_and_users.rb | |
parent | e388691e4a5b5b69be903c7eceb606b853719cd5 (diff) | |
download | gitlab-ce-a0b4a462b0c6f333651ae9e0c0ca1e5794e7b4e1.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db/post_migrate/20210311093723_add_partial_index_on_ci_pipelines_by_cancelable_status_and_users.rb')
-rw-r--r-- | db/post_migrate/20210311093723_add_partial_index_on_ci_pipelines_by_cancelable_status_and_users.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/db/post_migrate/20210311093723_add_partial_index_on_ci_pipelines_by_cancelable_status_and_users.rb b/db/post_migrate/20210311093723_add_partial_index_on_ci_pipelines_by_cancelable_status_and_users.rb new file mode 100644 index 00000000000..176548be6e6 --- /dev/null +++ b/db/post_migrate/20210311093723_add_partial_index_on_ci_pipelines_by_cancelable_status_and_users.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class AddPartialIndexOnCiPipelinesByCancelableStatusAndUsers < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_ci_pipelines_on_user_id_and_id_and_cancelable_status' + INDEX_FILTER_CONDITION = <<~SQL + ((status)::text = ANY ( + ARRAY[ + ('running'::character varying)::text, + ('waiting_for_resource'::character varying)::text, + ('preparing'::character varying)::text, + ('pending'::character varying)::text, + ('created'::character varying)::text, + ('scheduled'::character varying)::text + ] + )) + SQL + + disable_ddl_transaction! + + def up + add_concurrent_index :ci_pipelines, [:user_id, :id], where: INDEX_FILTER_CONDITION, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :ci_pipelines, INDEX_NAME + end +end |