diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-09 21:08:48 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-09 21:08:48 +0000 |
commit | f29dae9f106150cd85d4fb107f1eb3b0281e6968 (patch) | |
tree | 3f3707bb3aa554c50e83b95ed9f0f0ff066edb3f /db | |
parent | 42c8bf63670403d3f5cd23091bb56edde7e187c6 (diff) | |
download | gitlab-ce-f29dae9f106150cd85d4fb107f1eb3b0281e6968.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20201103192526_schedule_populate_has_vulnerabilities.rb | 24 | ||||
-rw-r--r-- | db/schema_migrations/20201103192526 | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/db/post_migrate/20201103192526_schedule_populate_has_vulnerabilities.rb b/db/post_migrate/20201103192526_schedule_populate_has_vulnerabilities.rb new file mode 100644 index 00000000000..bed90af09dc --- /dev/null +++ b/db/post_migrate/20201103192526_schedule_populate_has_vulnerabilities.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class SchedulePopulateHasVulnerabilities < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + BATCH_SIZE = 1_000 + DELAY_INTERVAL = 2.minutes + MIGRATION_CLASS = 'PopulateHasVulnerabilities' + + disable_ddl_transaction! + + def up + Gitlab::BackgroundMigration::PopulateHasVulnerabilities::Vulnerability.distinct.each_batch(of: BATCH_SIZE, column: :project_id) do |batch, index| + project_ids = batch.pluck(:project_id) + + migrate_in(index * DELAY_INTERVAL, MIGRATION_CLASS, project_ids) + end + end + + def down + # no-op + end +end diff --git a/db/schema_migrations/20201103192526 b/db/schema_migrations/20201103192526 new file mode 100644 index 00000000000..8fe11ed16d6 --- /dev/null +++ b/db/schema_migrations/20201103192526 @@ -0,0 +1 @@ +bb137c3a41a40e740f8ae65b43d7f9218f52d6d5eaf53c8a64b3336a8f16141b
\ No newline at end of file |