diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-11 21:14:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-11 21:14:04 +0300 |
commit | 11c2b8eff6ca5360fb0f732b23b764d2a0b81be5 (patch) | |
tree | 7f92622462127ff24023283133f81d9c4b2f6842 /db | |
parent | e40f19ef830c5863089bc6a7a73e6695efa60a13 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20211102103127_add_temp_index_to_vulnerability_occurrences.rb | 15 | ||||
-rw-r--r-- | db/post_migrate/20211102114802_update_vulnerability_occurrences_location.rb | 22 | ||||
-rw-r--r-- | db/schema_migrations/20211102103127 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20211102114802 | 1 | ||||
-rw-r--r-- | db/structure.sql | 2 |
5 files changed, 41 insertions, 0 deletions
diff --git a/db/post_migrate/20211102103127_add_temp_index_to_vulnerability_occurrences.rb b/db/post_migrate/20211102103127_add_temp_index_to_vulnerability_occurrences.rb new file mode 100644 index 00000000000..4aee79950dc --- /dev/null +++ b/db/post_migrate/20211102103127_add_temp_index_to_vulnerability_occurrences.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddTempIndexToVulnerabilityOccurrences < Gitlab::Database::Migration[1.0] + INDEX_NAME = 'vulnerability_occurrences_location_temp_index' + + disable_ddl_transaction! + + def up + add_concurrent_index :vulnerability_occurrences, :id, where: 'location IS NULL', name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :vulnerability_occurrences, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20211102114802_update_vulnerability_occurrences_location.rb b/db/post_migrate/20211102114802_update_vulnerability_occurrences_location.rb new file mode 100644 index 00000000000..20618b78391 --- /dev/null +++ b/db/post_migrate/20211102114802_update_vulnerability_occurrences_location.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class UpdateVulnerabilityOccurrencesLocation < Gitlab::Database::Migration[1.0] + BATCH_SIZE = 20_000 + DELAY_INTERVAL = 3.minutes + MIGRATION_NAME = 'UpdateVulnerabilityOccurrencesLocation' + + disable_ddl_transaction! + + def up + relation = Gitlab::BackgroundMigration::UpdateVulnerabilityOccurrencesLocation::Occurrence.where(location: nil) + queue_background_migration_jobs_by_range_at_intervals(relation, + MIGRATION_NAME, + DELAY_INTERVAL, + batch_size: BATCH_SIZE, + track_jobs: true) + end + + def down + # no-op + end +end diff --git a/db/schema_migrations/20211102103127 b/db/schema_migrations/20211102103127 new file mode 100644 index 00000000000..2ce33ad085a --- /dev/null +++ b/db/schema_migrations/20211102103127 @@ -0,0 +1 @@ +450028c90cb92f5ce3f8239eb56364b83ed025839aaf305b7ceb4fda077681b1
\ No newline at end of file diff --git a/db/schema_migrations/20211102114802 b/db/schema_migrations/20211102114802 new file mode 100644 index 00000000000..35d3a25f3cb --- /dev/null +++ b/db/schema_migrations/20211102114802 @@ -0,0 +1 @@ +a3f9fcac354cccfdfc42b8f5baab651cb65ca60e4474ce937ab25b552bfe483c
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index c2bf310d3c6..f1c6725d927 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -27795,6 +27795,8 @@ CREATE UNIQUE INDEX vulnerability_feedback_unique_idx ON vulnerability_feedback CREATE UNIQUE INDEX vulnerability_occurrence_pipelines_on_unique_keys ON vulnerability_occurrence_pipelines USING btree (occurrence_id, pipeline_id); +CREATE INDEX vulnerability_occurrences_location_temp_index ON vulnerability_occurrences USING btree (id) WHERE (location IS NULL); + CREATE UNIQUE INDEX work_item_types_namespace_id_and_name_unique ON work_item_types USING btree (namespace_id, btrim(lower(name))); ALTER INDEX analytics_cycle_analytics_issue_stage_events_pkey ATTACH PARTITION gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_00_pkey; |