diff --git a/app/models/conversation.rb b/app/models/conversation.rb index 119df82e9..43c2b0410 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -27,6 +27,7 @@ # # Indexes # +# conv_acid_inbid_stat_asgnid_idx (account_id,inbox_id,status,assignee_id) # index_conversations_on_account_id (account_id) # index_conversations_on_account_id_and_display_id (account_id,display_id) UNIQUE # index_conversations_on_assignee_id_and_account_id (assignee_id,account_id) diff --git a/app/models/inbox.rb b/app/models/inbox.rb index 0c0204da1..bc086ae87 100644 --- a/app/models/inbox.rb +++ b/app/models/inbox.rb @@ -26,7 +26,8 @@ # # Indexes # -# index_inboxes_on_account_id (account_id) +# index_inboxes_on_account_id (account_id) +# index_inboxes_on_channel_id_and_channel_type (channel_id,channel_type) # class Inbox < ApplicationRecord diff --git a/config/app.yml b/config/app.yml index 5a5b23178..ec419bcc7 100644 --- a/config/app.yml +++ b/config/app.yml @@ -1,5 +1,5 @@ shared: &shared - version: '2.14.0' + version: '2.15.0' development: <<: *shared diff --git a/db/migrate/20230315105847_add_indexes_for_common_queries.rb b/db/migrate/20230315105847_add_indexes_for_common_queries.rb new file mode 100644 index 000000000..b16adb71f --- /dev/null +++ b/db/migrate/20230315105847_add_indexes_for_common_queries.rb @@ -0,0 +1,11 @@ +class AddIndexesForCommonQueries < ActiveRecord::Migration[6.1] + # disabling ddl transaction is required for concurrent index creation + # https://thoughtbot.com/blog/how-to-create-postgres-indexes-concurrently-in + disable_ddl_transaction! + + def change + ActiveRecord::Migration[6.1].add_index(:inboxes, [:channel_id, :channel_type], algorithm: :concurrently) + ActiveRecord::Migration[6.1].add_index(:conversations, [:account_id, :inbox_id, :status, :assignee_id], name: 'conv_acid_inbid_stat_asgnid_idx', + algorithm: :concurrently) + end +end diff --git a/db/schema.rb b/db/schema.rb index eb13c753d..88cc8ef1d 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: 2023_03_13_113920) do +ActiveRecord::Schema.define(version: 2023_03_15_105847) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" @@ -448,6 +448,7 @@ ActiveRecord::Schema.define(version: 2023_03_13_113920) do t.datetime "assignee_last_seen_at" t.datetime "first_reply_created_at" t.index ["account_id", "display_id"], name: "index_conversations_on_account_id_and_display_id", unique: true + t.index ["account_id", "inbox_id", "status", "assignee_id"], name: "conv_acid_inbid_stat_asgnid_idx" t.index ["account_id"], name: "index_conversations_on_account_id" t.index ["assignee_id", "account_id"], name: "index_conversations_on_assignee_id_and_account_id" t.index ["campaign_id"], name: "index_conversations_on_campaign_id" @@ -576,6 +577,7 @@ ActiveRecord::Schema.define(version: 2023_03_13_113920) do t.jsonb "auto_assignment_config", default: {} t.boolean "lock_to_single_conversation", default: false, null: false t.index ["account_id"], name: "index_inboxes_on_account_id" + t.index ["channel_id", "channel_type"], name: "index_inboxes_on_channel_id_and_channel_type" end create_table "installation_configs", force: :cascade do |t| diff --git a/lib/tasks/ip_lookup.rake b/lib/tasks/ip_lookup.rake index f1ae80100..7087e6de1 100644 --- a/lib/tasks/ip_lookup.rake +++ b/lib/tasks/ip_lookup.rake @@ -4,7 +4,7 @@ namespace :ip_lookup do task setup: :environment do next if File.exist?(GeocoderConfiguration::LOOK_UP_DB) - ip_lookup_api_key = ENV.fetch('IP_LOOKUP_API_KEY') + ip_lookup_api_key = ENV.fetch('IP_LOOKUP_API_KEY', nil) next if ip_lookup_api_key.blank? puts '[rake ip_lookup:setup] Fetch GeoLite2-City database' diff --git a/package.json b/package.json index 6f19d9fc2..360751991 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@chatwoot/chatwoot", - "version": "2.14.0", + "version": "2.15.0", "license": "MIT", "scripts": { "eslint": "eslint app/**/*.{js,vue}",