Add index to leaderboards where not deleted

Based on a suggestion from pg_analyze
This commit is contained in:
Max Wofford
2025-06-09 10:41:17 -04:00
parent c8c3348a59
commit 7c835d7801
2 changed files with 11 additions and 1 deletions

View File

@@ -0,0 +1,9 @@
class AddIndexToLeaderboardsStartDate < ActiveRecord::Migration[8.0]
disable_ddl_transaction!
def change
add_index :leaderboards, :start_date,
where: "deleted_at IS NULL",
algorithm: :concurrently
end
end

3
db/schema.rb generated
View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2025_06_08_205244) do
ActiveRecord::Schema[8.0].define(version: 2025_06_09_143856) do
create_schema "pganalyze"
# These are extensions that must be enabled in order to support this database
@@ -250,6 +250,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_08_205244) do
t.datetime "finished_generating_at"
t.datetime "deleted_at"
t.integer "period_type", default: 0, null: false
t.index ["start_date"], name: "index_leaderboards_on_start_date", where: "(deleted_at IS NULL)"
end
create_table "mailing_addresses", force: :cascade do |t|