about summary refs log tree commit diff
path: root/db/migrate
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2020-04-15 20:33:24 +0200
committerGitHub <noreply@github.com>2020-04-15 20:33:24 +0200
commit5edff32733eff2cbffbf614b31eea85da8dc3aaf (patch)
treeb0ab38cbf8793f47017e2151de5dd32bdd83a29a /db/migrate
parent5524258da9bc1d62b1396d19c672d3a8335ffbc5 (diff)
Change delivery failure tracking to work with hostnames instead of URLs (#13437)
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20200407201300_create_unavailable_domains.rb9
-rw-r--r--db/migrate/20200407202420_migrate_unavailable_inboxes.rb16
2 files changed, 25 insertions, 0 deletions
diff --git a/db/migrate/20200407201300_create_unavailable_domains.rb b/db/migrate/20200407201300_create_unavailable_domains.rb
new file mode 100644
index 000000000..56b477da5
--- /dev/null
+++ b/db/migrate/20200407201300_create_unavailable_domains.rb
@@ -0,0 +1,9 @@
+class CreateUnavailableDomains < ActiveRecord::Migration[5.2]
+  def change
+    create_table :unavailable_domains do |t|
+      t.string :domain, default: '', null: false, index: { unique: true }
+
+      t.timestamps
+    end
+  end
+end
diff --git a/db/migrate/20200407202420_migrate_unavailable_inboxes.rb b/db/migrate/20200407202420_migrate_unavailable_inboxes.rb
new file mode 100644
index 000000000..0dce26c6f
--- /dev/null
+++ b/db/migrate/20200407202420_migrate_unavailable_inboxes.rb
@@ -0,0 +1,16 @@
+class MigrateUnavailableInboxes < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    urls = Redis.current.smembers('unavailable_inboxes')
+
+    urls.each do |url|
+      host = Addressable::URI.parse(url).normalized_host
+      UnavailableDomain.create(domain: host)
+    end
+
+    Redis.current.del(*(['unavailable_inboxes'] + Redis.current.keys('exhausted_deliveries:*')))
+  end
+
+  def down; end
+end