Skip to content

Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬

chore: add index on articles category_id (#16319)

Vishnu Narayanan7a86dea8d0be
diff --git a/app/models/article.rb b/app/models/article.rb
index 9d62e08f9f4..555992f59c5 100644
--- a/app/models/article.rb
+++ b/app/models/article.rb
@@ -28,6 +28,7 @@
# index_articles_on_account_id (account_id)
# index_articles_on_associated_article_id (associated_article_id)
# index_articles_on_author_id (author_id)
+# index_articles_on_category_id (category_id)
# index_articles_on_portal_id (portal_id)
# index_articles_on_slug (slug) UNIQUE
# index_articles_on_status (status)
diff --git a/db/migrate/20261019143116_add_index_to_articles_category_id.rb b/db/migrate/20261019143116_add_index_to_articles_category_id.rb
new file mode 100644
index 00000000000..864d0a36604
--- /dev/null
+++ b/db/migrate/20261019143116_add_index_to_articles_category_id.rb
@@ -0,0 +1,7 @@
+class AddIndexToArticlesCategoryId < ActiveRecord::Migration[7.2]
+ disable_ddl_transaction!
+
+ def change
+ add_index :articles, :category_id, algorithm: :concurrently
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 736466fc0f3..6a3d3c0815f 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[7.1].define(version: 2026_10_17_230231) do
+ActiveRecord::Schema[7.1].define(version: 2026_10_19_143116) do
# These extensions should be enabled to support this database
enable_extension "pg_stat_statements"
enable_extension "pg_trgm"
@@ -222,6 +222,7 @@ ActiveRecord::Schema[7.1].define(version: 2026_10_17_230231) do
t.index ["account_id"], name: "index_articles_on_account_id"
t.index ["associated_article_id"], name: "index_articles_on_associated_article_id"
t.index ["author_id"], name: "index_articles_on_author_id"
+ t.index ["category_id"], name: "index_articles_on_category_id"
t.index ["portal_id"], name: "index_articles_on_portal_id"
t.index ["slug"], name: "index_articles_on_slug", unique: true
t.index ["status"], name: "index_articles_on_status"