diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-22 03:09:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-22 03:09:24 +0300 |
commit | e3e139096eee0cce110d56744aa9431c8f801278 (patch) | |
tree | cec6a44abda1c8c3e114abc4955000a6e8faa2d0 /db | |
parent | 0c843254fcdfc9c25b0bca0130465ee2092515cd (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20200416111111_migrate_vulnerability_dismissals.rb | 37 | ||||
-rw-r--r-- | db/structure.sql | 1 |
2 files changed, 38 insertions, 0 deletions
diff --git a/db/post_migrate/20200416111111_migrate_vulnerability_dismissals.rb b/db/post_migrate/20200416111111_migrate_vulnerability_dismissals.rb new file mode 100644 index 00000000000..6ec8b991968 --- /dev/null +++ b/db/post_migrate/20200416111111_migrate_vulnerability_dismissals.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +class MigrateVulnerabilityDismissals < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + MIGRATION = 'UpdateVulnerabilitiesToDismissed'.freeze + BATCH_SIZE = 500 + DELAY_INTERVAL = 2.minutes.to_i + + class Vulnerability < ActiveRecord::Base + self.table_name = 'vulnerabilities' + self.inheritance_column = :_type_disabled + + include ::EachBatch + end + + def up + return unless Gitlab.ee? + + Vulnerability.select('project_id').group(:project_id).each_batch(of: BATCH_SIZE, column: "project_id") do |project_batch, index| + batch_delay = (index - 1) * BATCH_SIZE * DELAY_INTERVAL + + project_batch.each_with_index do |project, project_batch_index| + project_delay = project_batch_index * DELAY_INTERVAL + migrate_in(batch_delay + project_delay, MIGRATION, project[:project_id]) + end + end + end + + def down + # nothing to do + end +end diff --git a/db/structure.sql b/db/structure.sql index 9035626fb89..fb222a570a2 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -13256,6 +13256,7 @@ COPY "schema_migrations" (version) FROM STDIN; 20200415161021 20200415161206 20200415192656 +20200416111111 20200416120128 20200416120354 \. |