about summary refs log tree commit diff
path: root/db/migrate/20190820003045_update_statuses_index.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-08-22 21:55:56 +0200
committermultiple creatures <dev@multiple-creature.party>2020-02-27 13:43:13 -0600
commit422b59808b4818171e057e1a459de153816bf505 (patch)
tree5320830d5d3146c9032a0e975a069a4a1be76253 /db/migrate/20190820003045_update_statuses_index.rb
parent165f53238655bf87f27981282ca8deb71474c86f (diff)
port tootsuite#11623 to monsterfork: Add soft delete for statuses for instant deletes through API
* Add soft delete for statuses to allow them to appear instant

* Allow reporting soft-deleted statuses and show them in the admin UI

* Change index for getting an account's statuses
Diffstat (limited to 'db/migrate/20190820003045_update_statuses_index.rb')
-rw-r--r--db/migrate/20190820003045_update_statuses_index.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/db/migrate/20190820003045_update_statuses_index.rb b/db/migrate/20190820003045_update_statuses_index.rb
new file mode 100644
index 000000000..5c2ea1f6a
--- /dev/null
+++ b/db/migrate/20190820003045_update_statuses_index.rb
@@ -0,0 +1,13 @@
+class UpdateStatusesIndex < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    safety_assured { add_index :statuses, [:account_id, :id, :visibility, :updated_at], where: 'deleted_at IS NULL', order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20190820 }
+    remove_index :statuses, name: :index_statuses_20180106
+  end
+
+  def down
+    safety_assured { add_index :statuses, [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 }
+    remove_index :statuses, name: :index_statuses_20190820
+  end
+end