2020-07-08 08:09:33 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class UnconfirmWrongfullyVerifiedEmails < ActiveRecord::Migration[6.0]
|
|
|
|
include Gitlab::Database::MigrationHelpers
|
|
|
|
|
|
|
|
DOWNTIME = false
|
|
|
|
|
|
|
|
disable_ddl_transaction!
|
|
|
|
|
|
|
|
INTERVAL = 5.minutes.to_i
|
2020-07-12 23:09:12 -04:00
|
|
|
BATCH_SIZE = 500
|
2020-07-08 08:09:33 -04:00
|
|
|
MIGRATION = 'WrongfullyConfirmedEmailUnconfirmer'
|
|
|
|
EMAIL_INDEX_NAME = 'tmp_index_for_email_unconfirmation_migration'
|
|
|
|
|
2020-07-28 17:09:30 -04:00
|
|
|
class ApplicationSetting < ActiveRecord::Base
|
|
|
|
self.table_name = 'application_settings'
|
|
|
|
end
|
|
|
|
|
2020-07-08 08:09:33 -04:00
|
|
|
class Email < ActiveRecord::Base
|
|
|
|
include EachBatch
|
|
|
|
end
|
|
|
|
|
|
|
|
def up
|
|
|
|
add_concurrent_index :emails, :id, where: 'confirmed_at IS NOT NULL', name: EMAIL_INDEX_NAME
|
|
|
|
|
2020-07-28 17:09:30 -04:00
|
|
|
ApplicationSetting.reset_column_information
|
|
|
|
|
|
|
|
setting_record = ApplicationSetting.last
|
|
|
|
return unless setting_record&.send_user_confirmation_email
|
|
|
|
|
2020-07-08 08:09:33 -04:00
|
|
|
queue_background_migration_jobs_by_range_at_intervals(Email,
|
|
|
|
MIGRATION,
|
|
|
|
INTERVAL,
|
|
|
|
batch_size: BATCH_SIZE)
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
remove_concurrent_index_by_name(:emails, EMAIL_INDEX_NAME)
|
|
|
|
end
|
|
|
|
end
|