about summary refs log tree commit diff
path: root/db/migrate/20170507141759_optimize_index_subscriptions.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20170507141759_optimize_index_subscriptions.rb')
-rw-r--r--db/migrate/20170507141759_optimize_index_subscriptions.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/db/migrate/20170507141759_optimize_index_subscriptions.rb b/db/migrate/20170507141759_optimize_index_subscriptions.rb
new file mode 100644
index 000000000..26acd5c4d
--- /dev/null
+++ b/db/migrate/20170507141759_optimize_index_subscriptions.rb
@@ -0,0 +1,11 @@
+class OptimizeIndexSubscriptions < ActiveRecord::Migration[5.0]
+  def up
+    add_index :subscriptions, [:account_id, :callback_url], unique: true
+    remove_index :subscriptions, [:callback_url, :account_id]
+  end
+
+  def down
+    add_index :subscriptions, [:callback_url, :account_id], unique: true
+    remove_index :subscriptions, [:account_id, :callback_url]
+  end
+end