2018-03-17 18:26:18 +05:30
|
|
|
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
|
|
|
|
# for more information on how to write migrations for GitLab.
|
|
|
|
|
2019-01-03 12:48:30 +05:30
|
|
|
class NormalizeExternUidFromIdentities < ActiveRecord::Migration
|
2018-03-17 18:26:18 +05:30
|
|
|
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
|