Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cleanup_personal_access_tokens_with_nil_expires_at.rb « background_migration « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e8ee2a4c2518908b55651b19e84872c5525eb176 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

module Gitlab
  module BackgroundMigration
    # Clean up personal access tokens with expires_at value is nil
    # and set the value to new default 365 days
    class CleanupPersonalAccessTokensWithNilExpiresAt < BatchedMigrationJob
      feature_category :system_access

      EXPIRES_AT_DEFAULT = 365.days.from_now

      scope_to ->(relation) { relation.where(expires_at: nil) }
      operation_name :update_all

      def perform
        each_sub_batch do |sub_batch|
          sub_batch.update_all(expires_at: EXPIRES_AT_DEFAULT)
        end
      end
    end
  end
end