debian-mirror-gitlab/db/post_migrate/20200615111857_unconfirm_wrongfully_verified_emails.rb

41 lines
1.1 KiB
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
class UnconfirmWrongfullyVerifiedEmails < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
INTERVAL = 5.minutes.to_i
BATCH_SIZE = 500
MIGRATION = 'WrongfullyConfirmedEmailUnconfirmer'
EMAIL_INDEX_NAME = 'tmp_index_for_email_unconfirmation_migration'
2020-08-09 18:53:13 +05:30
class ApplicationSetting < ActiveRecord::Base
self.table_name = 'application_settings'
end
2020-07-28 23:09:34 +05:30
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-08-09 18:53:13 +05:30
ApplicationSetting.reset_column_information
setting_record = ApplicationSetting.last
return unless setting_record&.send_user_confirmation_email
2020-07-28 23:09:34 +05:30
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