diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
commit | b595cb0c1dec83de5bdee18284abe86614bed33b (patch) | |
tree | 8c3d4540f193c5ff98019352f554e921b3a41a72 /db/post_migrate/20220706132238_add_indices_on_security_scans_info_column.rb | |
parent | 2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff) |
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'db/post_migrate/20220706132238_add_indices_on_security_scans_info_column.rb')
-rw-r--r-- | db/post_migrate/20220706132238_add_indices_on_security_scans_info_column.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/db/post_migrate/20220706132238_add_indices_on_security_scans_info_column.rb b/db/post_migrate/20220706132238_add_indices_on_security_scans_info_column.rb new file mode 100644 index 00000000000..48dc5b5d84a --- /dev/null +++ b/db/post_migrate/20220706132238_add_indices_on_security_scans_info_column.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class AddIndicesOnSecurityScansInfoColumn < Gitlab::Database::Migration[2.0] + INDEX_NAME_ON_ERRORS = :index_security_scans_on_length_of_errors + INDEX_NAME_ON_WARNINGS = :index_security_scans_on_length_of_warnings + + disable_ddl_transaction! + + def up + add_concurrent_index( + :security_scans, + "pipeline_id, jsonb_array_length(COALESCE((security_scans.info -> 'errors'::text), '[]'::jsonb))", + name: INDEX_NAME_ON_ERRORS + ) + + add_concurrent_index( + :security_scans, + "pipeline_id, jsonb_array_length(COALESCE((security_scans.info -> 'warnings'::text), '[]'::jsonb))", + name: INDEX_NAME_ON_WARNINGS + ) + end + + def down + remove_concurrent_index_by_name :security_scans, INDEX_NAME_ON_ERRORS + remove_concurrent_index_by_name :security_scans, INDEX_NAME_ON_WARNINGS + end +end |