]> cat aescling's git repositories - mastodon.git/commitdiff
Add effective index to subscriptions (#2885)
authoralpaca-tc <alpaca-tc@alpaca.tc>
Sun, 7 May 2017 17:00:20 +0000 (02:00 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Sun, 7 May 2017 17:00:20 +0000 (19:00 +0200)
db/migrate/20170507141759_optimize_index_subscriptions.rb [new file with mode: 0644]
db/schema.rb

diff --git a/db/migrate/20170507141759_optimize_index_subscriptions.rb b/db/migrate/20170507141759_optimize_index_subscriptions.rb
new file mode 100644 (file)
index 0000000..26acd5c
--- /dev/null
@@ -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
index f6a13671c8bec18415eb0de883d3c07f3443498a..21fce0df78185ce0ed4219e57382c0b9282979a1 100644 (file)
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 20170425202925) do
+ActiveRecord::Schema.define(version: 20170507141759) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -288,7 +288,7 @@ ActiveRecord::Schema.define(version: 20170425202925) do
     t.datetime "created_at",                                  null: false
     t.datetime "updated_at",                                  null: false
     t.datetime "last_successful_delivery_at"
-    t.index ["callback_url", "account_id"], name: "index_subscriptions_on_callback_url_and_account_id", unique: true, using: :btree
+    t.index ["account_id", "callback_url"], name: "index_subscriptions_on_account_id_and_callback_url", unique: true, using: :btree
   end
 
   create_table "tags", force: :cascade do |t|