debian-mirror-gitlab/db/migrate/20191120084627_add_encrypted_fields_to_application_settings.rb

35 lines
1 KiB
Ruby
Raw Normal View History

2019-12-04 20:38:33 +05:30
# frozen_string_literal: true
class AddEncryptedFieldsToApplicationSettings < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
PLAINTEXT_ATTRIBUTES = %w[
akismet_api_key
elasticsearch_aws_secret_access_key
recaptcha_private_key
recaptcha_site_key
slack_app_secret
slack_app_verification_token
].freeze
2020-05-24 23:13:21 +05:30
# rubocop:disable Migration/PreventStrings
# rubocop:disable Migration/AddLimitToTextColumns
2019-12-04 20:38:33 +05:30
def up
PLAINTEXT_ATTRIBUTES.each do |plaintext_attribute|
add_column :application_settings, "encrypted_#{plaintext_attribute}", :text
add_column :application_settings, "encrypted_#{plaintext_attribute}_iv", :string, limit: 255
end
end
2020-05-24 23:13:21 +05:30
# rubocop:enable Migration/AddLimitToTextColumns
# rubocop:enable Migration/PreventStrings
2019-12-04 20:38:33 +05:30
def down
PLAINTEXT_ATTRIBUTES.each do |plaintext_attribute|
remove_column :application_settings, "encrypted_#{plaintext_attribute}"
remove_column :application_settings, "encrypted_#{plaintext_attribute}_iv"
end
end
end