mirror of
https://github.com/gitlabhq/gitlabhq.git
synced 2025-08-01 16:46:16 +00:00
29 lines
667 B
Ruby
29 lines
667 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Gitlab
|
|
module BackgroundMigration
|
|
class RemoveOldJobTokens < BatchedMigrationJob
|
|
operation_name :remove_old_tokens
|
|
feature_category :continuous_integration
|
|
|
|
ACTIVE_STATUSES = %w[
|
|
waiting_for_resource
|
|
preparing
|
|
waiting_for_callback
|
|
pending
|
|
running
|
|
].freeze
|
|
|
|
def perform
|
|
each_sub_batch do |sub_batch|
|
|
sub_batch
|
|
.where.not(status: ACTIVE_STATUSES)
|
|
.where.not(token_encrypted: nil)
|
|
.where(created_at: ...1.month.ago)
|
|
.update_all(token_encrypted: nil)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|