gitlab-org--gitlab-foss/db/post_migrate/20170921101004_normalize_ld...

30 lines
701 B
Ruby
Raw Normal View History

2017-09-21 17:32:21 +00:00
# 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
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
2017-10-03 22:27:52 +00:00
MIGRATION = 'NormalizeLdapExternUidsRange'.freeze
DELAY_INTERVAL = 10.seconds
2017-09-21 17:32:21 +00:00
2017-10-03 22:27:52 +00:00
disable_ddl_transaction!
2017-10-03 22:15:23 +00:00
2017-10-03 22:27:52 +00:00
class Identity < ActiveRecord::Base
include EachBatch
2017-09-21 17:32:21 +00:00
2017-10-03 22:27:52 +00:00
self.table_name = 'identities'
2017-09-21 17:32:21 +00:00
end
def up
ldap_identities = Identity.where("provider like 'ldap%'")
2017-10-03 22:27:52 +00:00
if ldap_identities.any?
queue_background_migration_jobs_by_range_at_intervals(Identity, MIGRATION, DELAY_INTERVAL)
2017-09-21 17:32:21 +00:00
end
end
def down
end
end