diff --git a/db/migrate/20191030112559_add_index_to_notifications.rb b/db/migrate/20191030112559_add_index_to_notifications.rb
new file mode 100644
index 00000000000..69d36d2f4d6
--- /dev/null
+++ b/db/migrate/20191030112559_add_index_to_notifications.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexToNotifications < ActiveRecord::Migration[6.0]
+  disable_ddl_transaction!
+
+  def up
+    if !index_exists?(:notifications, [:topic_id, :post_number])
+      add_index :notifications, [:topic_id, :post_number], algorithm: :concurrently
+    end
+  end
+
+  def down
+    raise ActiveRecord::IrreversibleMigration
+  end
+end