20200407202420_migrate_unavailable_inboxes.rb 497 B

123456789101112131415161718192021
  1. class MigrateUnavailableInboxes < ActiveRecord::Migration[5.2]
  2. disable_ddl_transaction!
  3. def up
  4. urls = Redis.current.smembers('unavailable_inboxes')
  5. hosts = urls.map do |url|
  6. Addressable::URI.parse(url).normalized_host
  7. end.compact.uniq
  8. UnavailableDomain.delete_all
  9. hosts.each do |host|
  10. UnavailableDomain.create(domain: host)
  11. end
  12. Redis.current.del(*(['unavailable_inboxes'] + Redis.current.keys('exhausted_deliveries:*')))
  13. end
  14. def down; end
  15. end