about summary refs log tree commit diff
path: root/db/migrate
diff options
context:
space:
mode:
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