summaryrefslogtreecommitdiff
path: root/lib/gitlab/background_migration/prune_stale_project_export_jobs.rb
blob: a91cda2c427d694ee3ba470b6cbee866e64728ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

module Gitlab
  module BackgroundMigration
    # Background migration for deleting stale project import jobs
    class PruneStaleProjectExportJobs < BatchedMigrationJob
      EXPIRES_IN = 7.days

      scope_to ->(relation) { relation.where("updated_at < ?", EXPIRES_IN.ago) }
      operation_name :delete_all

      def perform
        each_sub_batch(&:delete_all)
      end
    end
  end
end