diff options
Diffstat (limited to 'db/post_migrate/20210701111909_backfill_issues_upvotes_count.rb')
-rw-r--r-- | db/post_migrate/20210701111909_backfill_issues_upvotes_count.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/db/post_migrate/20210701111909_backfill_issues_upvotes_count.rb b/db/post_migrate/20210701111909_backfill_issues_upvotes_count.rb new file mode 100644 index 00000000000..0afc0bc1d08 --- /dev/null +++ b/db/post_migrate/20210701111909_backfill_issues_upvotes_count.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class BackfillIssuesUpvotesCount < ActiveRecord::Migration[6.1] + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + MIGRATION = 'BackfillUpvotesCountOnIssues' + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 5_000 + + def up + scope = Issue.joins("INNER JOIN award_emoji e ON e.awardable_id = issues.id AND e.awardable_type = 'Issue' AND e.name = 'thumbsup'") + + queue_background_migration_jobs_by_range_at_intervals( + scope, + MIGRATION, + DELAY_INTERVAL, + batch_size: BATCH_SIZE + ) + end + + def down + # no-op + end +end |