summaryrefslogtreecommitdiff
path: root/db/post_migrate/20170921101004_normalize_ldap_extern_uids.rb
blob: 9080acee1d66112482596c684b9167a271a74c3f (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
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class NormalizeLdapExternUids < ActiveRecord::Migration[4.2]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false
  MIGRATION = 'NormalizeLdapExternUidsRange'.freeze
  DELAY_INTERVAL = 10.seconds

  disable_ddl_transaction!

  class Identity < ActiveRecord::Base
    include EachBatch

    self.table_name = 'identities'
  end

  def up
    ldap_identities = Identity.where("provider like 'ldap%'")

    if ldap_identities.any?
      queue_background_migration_jobs_by_range_at_intervals(Identity, MIGRATION, DELAY_INTERVAL)
    end
  end

  def down
  end
end