From 1ecae86d4f3b5ae73ca6fbc4b9e4a0dad51dea87 Mon Sep 17 00:00:00 2001 From: takayamaki Date: Tue, 5 Sep 2017 19:30:01 +0900 Subject: [PATCH] add index_notifications_on_id_and_account_id_and_activity_type on notifications table (#4750) --- ...add_index_id_account_id_activity_type_on_notifications.rb | 5 +++++ db/schema.rb | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170905044538_add_index_id_account_id_activity_type_on_notifications.rb diff --git a/db/migrate/20170905044538_add_index_id_account_id_activity_type_on_notifications.rb b/db/migrate/20170905044538_add_index_id_account_id_activity_type_on_notifications.rb new file mode 100644 index 0000000000..c47cea9e26 --- /dev/null +++ b/db/migrate/20170905044538_add_index_id_account_id_activity_type_on_notifications.rb @@ -0,0 +1,5 @@ +class AddIndexIdAccountIdActivityTypeOnNotifications < ActiveRecord::Migration[5.1] + def change + add_index :notifications, [:id, :account_id, :activity_type], order: { id: :desc } + end +end diff --git a/db/schema.rb b/db/schema.rb index c3a2581e3d..ea7edc2f9c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170901142658) do +ActiveRecord::Schema.define(version: 20170905044538) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -180,6 +180,7 @@ ActiveRecord::Schema.define(version: 20170901142658) do t.integer "from_account_id" t.index ["account_id", "activity_id", "activity_type"], name: "account_activity", unique: true t.index ["activity_id", "activity_type"], name: "index_notifications_on_activity_id_and_activity_type" + t.index ["id", "account_id", "activity_type"], name: "index_notifications_on_id_and_account_id_and_activity_type", order: { id: :desc } end create_table "oauth_access_grants", id: :serial, force: :cascade do |t|