about summary refs log blame commit diff
path: root/db/migrate/20200407202420_migrate_unavailable_inboxes.rb
blob: 8f9c687942b011723c95728efce7b534c3a14025 (plain) (tree)
1
2
3
4
5
6
7


                                                              
                                                
 





                                                 

                                            
                                                                                


               
class MigrateUnavailableInboxes < ActiveRecord::Migration[5.2]
  disable_ddl_transaction!

  def up
    redis = RedisConfiguration.pool.checkout
    urls = redis.smembers('unavailable_inboxes')

    hosts = urls.map do |url|
      Addressable::URI.parse(url).normalized_host
    end.compact.uniq

    UnavailableDomain.delete_all

    hosts.each do |host|
      UnavailableDomain.create(domain: host)
    end

    redis.del(*(['unavailable_inboxes'] + redis.keys('exhausted_deliveries:*')))
  end

  def down; end
end