summaryrefslogtreecommitdiff
path: root/db/post_migrate/20170828124518_downcase_gpg_key_user_email_on_gpg_signatures.rb
blob: a11a9b0669fc99a517fd710ee391f80e68449b9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class DowncaseGpgKeyUserEmailOnGpgSignatures < ActiveRecord::Migration
  DOWNTIME = false

  include Gitlab::Database::MigrationHelpers
  disable_ddl_transaction!

  class GpgSignature < ActiveRecord::Base
    self.table_name = 'gpg_signatures'

    include EachBatch
  end

  def up
    GpgSignature.each_batch do |relation|
      relation.update_all('gpg_key_user_email = LOWER(gpg_key_user_email)')
    end
  end

  def down
    # we can't revert the downcasing, but actually we don't need to really, as
    # downcasing the emails is not a harmful change.
  end
end