summaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20230907150100_add_index_account_stats_on_last_status_at_and_account_id.rb9
-rw-r--r--db/schema.rb3
2 files changed, 11 insertions, 1 deletions
diff --git a/db/migrate/20230907150100_add_index_account_stats_on_last_status_at_and_account_id.rb b/db/migrate/20230907150100_add_index_account_stats_on_last_status_at_and_account_id.rb
new file mode 100644
index 00000000000..17ac65547c5
--- /dev/null
+++ b/db/migrate/20230907150100_add_index_account_stats_on_last_status_at_and_account_id.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddIndexAccountStatsOnLastStatusAtAndAccountId < ActiveRecord::Migration[7.0]
+ disable_ddl_transaction!
+
+ def change
+ add_index :account_stats, [:last_status_at, :account_id], order: { last_status_at: 'DESC NULLS LAST' }, algorithm: :concurrently
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 21eff86bf70..37020c2d72b 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.0].define(version: 2023_09_04_134623) do
+ActiveRecord::Schema[7.0].define(version: 2023_09_07_150100) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -99,6 +99,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_09_04_134623) do
t.datetime "updated_at", precision: nil, null: false
t.datetime "last_status_at", precision: nil
t.index ["account_id"], name: "index_account_stats_on_account_id", unique: true
+ t.index ["last_status_at", "account_id"], name: "index_account_stats_on_last_status_at_and_account_id", order: { last_status_at: "DESC NULLS LAST" }
end
create_table "account_statuses_cleanup_policies", force: :cascade do |t|