about summary refs log tree commit diff
path: root/db/migrate/20200407202420_migrate_unavailable_inboxes.rb
blob: 92a3acb5d183914501f8ae3314275c49b800e7ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class MigrateUnavailableInboxes < ActiveRecord::Migration[5.2]
  disable_ddl_transaction!

  def up
    urls = Redis.current.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.current.del(*(['unavailable_inboxes'] + Redis.current.keys('exhausted_deliveries:*')))
  end

  def down; end
end