2022-07-16 23:28:13 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module BackgroundMigration
|
|
|
|
# Add expiry to all OAuth access tokens
|
|
|
|
class ExpireOAuthTokens < ::Gitlab::BackgroundMigration::BatchedMigrationJob
|
2023-01-13 00:05:48 +05:30
|
|
|
operation_name :update_oauth_tokens
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
def perform
|
|
|
|
each_sub_batch(
|
|
|
|
batching_scope: ->(relation) { relation.where(expires_in: nil) }
|
|
|
|
) do |sub_batch|
|
|
|
|
update_oauth_tokens(sub_batch)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def update_oauth_tokens(relation)
|
|
|
|
relation.update_all(expires_in: 7_200)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|