diff options
author | multiple creatures <dev@multiple-creature.party> | 2020-03-02 01:03:12 -0600 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2020-03-02 01:03:12 -0600 |
commit | 69ff9b18896efe4ec43dd249cde265360f2b9c63 (patch) | |
tree | cf9c96dbc2136470f49cbe28ae3985e50ddcd1b2 /db/migrate | |
parent | 416d51727ddb90c722df8587e5f2896722477fae (diff) |
hopefully this is the last of changes to `statuses` table indexes
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20200302214442_modify_status_index_20200301.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/db/migrate/20200302214442_modify_status_index_20200301.rb b/db/migrate/20200302214442_modify_status_index_20200301.rb new file mode 100644 index 000000000..9aef315c2 --- /dev/null +++ b/db/migrate/20200302214442_modify_status_index_20200301.rb @@ -0,0 +1,21 @@ +class ModifyStatusIndex20200301 < ActiveRecord::Migration[5.2] + def up + safety_assured do + remove_index :statuses, name: :index_statuses_20200301 + remove_index :statuses, name: :index_statuses_curated_20200301 + remove_index :statuses, name: :index_statuses_public_20200301 + remove_index :statuses, name: :index_statuses_local_20200301 + remove_index :statuses, name: :index_statuses_hidden_20200301 + + add_index :statuses, [:id, :account_id, :visibility, :created_at, :updated_at], where: 'deleted_at IS NULL', order: { id: :desc }, name: :index_statuses_20200301 + add_index :statuses, [:id, :account_id, :visibility], where: '(curated) OR (curated = TRUE) OR (curated IS TRUE)', order: { id: :desc }, name: :index_statuses_curated_20200301 + add_index :statuses, [:id, :account_id, :visibility], where: '(network) OR (network = TRUE) OR (network IS TRUE)', order: { id: :desc }, name: :index_statuses_network_20200301 + add_index :statuses, [:id, :account_id, :visibility], where: '((local) OR (local = TRUE) OR (uri IS NULL)) AND (deleted_at IS NULL)', order: { id: :desc }, name: :index_statuses_local_20200301 + add_index :statuses, [:id, :account_id, :visibility], where: 'visibility IN (0, 5) OR (visibility = 0) OR (visibility = 5)', order: { id: :desc }, name: :index_statuses_public_20200301 + add_index :statuses, [:id, :account_id, :visibility], where: 'visibility IN (0, 1, 5) OR (visibility = 0) OR (visibility = 1) OR (visibility = 5)', order: { id: :desc }, name: :index_statuses_public_unlisted_20200301 + add_index :statuses, [:id, :account_id, :visibility], where: '(NOT reply) OR (reply = FALSE) OR (reply IS FALSE) OR (in_reply_to_account_id = account_id)', name: :index_statuses_without_replies_20200301 + add_index :statuses, [:id, :account_id, :visibility], where: 'reblog_of_id IS NULL', name: :index_statuses_without_reblogs_20200301 + add_index :statuses, [:id, :account_id, :visibility], where: '(hidden) OR (hidden = FALSE) OR (NOT hidden)', name: :index_statuses_hidden_20200301 + end + end +end |