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

encrypt_runners_tokens.rb « background_migration « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ec64a73542e8b339a1640bfccc14abc194ea0e1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true

module Gitlab
  module BackgroundMigration
    # EncryptColumn migrates data from an unencrypted column - `foo`, say - to
    # an encrypted column - `encrypted_foo`, say.
    #
    # We only create a subclass here because we want to isolate this migration
    # (migrating unencrypted runner registration tokens to encrypted columns)
    # from other `EncryptColumns` migration. This class name is going to be
    # serialized and stored in Redis and later picked by Sidekiq, so we need to
    # create a separate class name in order to isolate these migration tasks.
    #
    # We can solve this differently, see tech debt issue:
    #
    # https://gitlab.com/gitlab-org/gitlab-foss/issues/54328
    #
    class EncryptRunnersTokens < EncryptColumns
      def perform(model, from, to)
        resource = "::Gitlab::BackgroundMigration::Models::EncryptColumns::#{model.to_s.capitalize}"
        model = resource.constantize
        attributes = model.encrypted_attributes.keys

        super(model, attributes, from, to)
      end

      def clear_migrated_values?
        false
      end
    end
  end
end