20200407202420_migrate_unavailable_inboxes.rb 545 B

123456789101112131415161718192021222324
  1. # frozen_string_literal: true
  2. class MigrateUnavailableInboxes < ActiveRecord::Migration[5.2]
  3. disable_ddl_transaction!
  4. def up
  5. redis = RedisConnection.pool.checkout
  6. urls = redis.smembers('unavailable_inboxes')
  7. hosts = urls.filter_map do |url|
  8. Addressable::URI.parse(url).normalized_host
  9. end.uniq
  10. UnavailableDomain.delete_all
  11. hosts.each do |host|
  12. UnavailableDomain.create(domain: host)
  13. end
  14. redis.del(*(['unavailable_inboxes'] + redis.keys('exhausted_deliveries:*')))
  15. end
  16. def down; end
  17. end