From ecb5c6554cab1c49ce560c0782023d38a6372234 Mon Sep 17 00:00:00 2001 From: Fosco Marotto Date: Sat, 2 Jan 2021 23:12:32 -0500 Subject: [PATCH] [index] add index on status_revisions.status_id --- app/models/chat_conversation_account.rb | 2 +- db/migrate/20210102225500_add_index_on_status_revisions.rb | 7 +++++++ db/schema.rb | 5 +++-- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20210102225500_add_index_on_status_revisions.rb diff --git a/app/models/chat_conversation_account.rb b/app/models/chat_conversation_account.rb index dad54cac..b2ac7bda 100644 --- a/app/models/chat_conversation_account.rb +++ b/app/models/chat_conversation_account.rb @@ -12,7 +12,7 @@ # is_approved :boolean default(FALSE), not null # created_at :datetime not null # updated_at :datetime not null -# unread_count :bigint(8) default(0), not null +# unread_count :bigint(8) default(0) # chat_message_expiration_policy :string # is_muted :boolean default(FALSE), not null # diff --git a/db/migrate/20210102225500_add_index_on_status_revisions.rb b/db/migrate/20210102225500_add_index_on_status_revisions.rb new file mode 100644 index 00000000..43479b66 --- /dev/null +++ b/db/migrate/20210102225500_add_index_on_status_revisions.rb @@ -0,0 +1,7 @@ +class AddIndexOnStatusRevisions < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def change + add_index :status_revisions, :status_id, algorithm: :concurrently + end +end diff --git a/db/schema.rb b/db/schema.rb index 0b23d182..93225d24 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: 2020_12_22_040559) do +ActiveRecord::Schema.define(version: 2021_01_02_225500) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" @@ -221,7 +221,7 @@ ActiveRecord::Schema.define(version: 2020_12_22_040559) do t.boolean "is_approved", default: false, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.bigint "unread_count", default: 0, null: false + t.bigint "unread_count", default: 0 t.string "chat_message_expiration_policy" t.boolean "is_muted", default: false, null: false t.index ["account_id"], name: "index_chat_conversation_accounts_on_account_id" @@ -720,6 +720,7 @@ ActiveRecord::Schema.define(version: 2020_12_22_040559) do t.string "text" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.index ["status_id"], name: "index_status_revisions_on_status_id" end create_table "status_stats", force: :cascade do |t|