about summary refs log tree commit diff
path: root/db/migrate
diff options
context:
space:
mode:
authorabcang <abcang1015@gmail.com>2021-04-27 01:57:46 +0900
committerGitHub <noreply@github.com>2021-04-26 18:57:46 +0200
commitd0fc69d7213cab03c57947cac94bad1fd9cc6dba (patch)
tree379835e0b485b6b24103ac60b5aa6855266fc070 /db/migrate
parentf78cbc0c32d5fc648c92b5e1de02105d6a8594c0 (diff)
Further improve the media attached status query for accounts (#16106)
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20210425135952_add_index_on_media_attachments_account_id_status_id.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/db/migrate/20210425135952_add_index_on_media_attachments_account_id_status_id.rb b/db/migrate/20210425135952_add_index_on_media_attachments_account_id_status_id.rb
new file mode 100644
index 000000000..5ef2d3c39
--- /dev/null
+++ b/db/migrate/20210425135952_add_index_on_media_attachments_account_id_status_id.rb
@@ -0,0 +1,13 @@
+class AddIndexOnMediaAttachmentsAccountIdStatusId < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    add_index :media_attachments, [:account_id, :status_id], order: { status_id: :desc }, algorithm: :concurrently
+    remove_index :media_attachments, :account_id, algorithm: :concurrently
+  end
+
+  def down
+    add_index :media_attachments, :account_id, algorithm: :concurrently
+    remove_index :media_attachments, [:account_id, :status_id], order: { status_id: :desc }, algorithm: :concurrently
+  end
+end