Skip to content

Index barstools.created_at#19

Merged
craigpotter merged 1 commit into
mainfrom
fix/created-at-index
Jul 18, 2026
Merged

Index barstools.created_at#19
craigpotter merged 1 commit into
mainfrom
fix/created-at-index

Conversation

@craigpotter

Copy link
Copy Markdown
Collaborator

Overview of change

Second of three follow-ups from the review pass behind #17 (feature / schema / accuracy fixes).

The barstools table grows by design, and its two most common access patterns both filter or sort on created_at: model pruning (WHERE created_at <= ?) and recent-first browsing. Neither had an index, so both scan the table once it gets large.

  • create_barstools_table stub: created_at now indexed for new installs
  • New add_created_at_index_to_barstools_table upgrade migration for existing installs, guarded with hasIndex so it no-ops if the index already exists (e.g. fresh installs that publish and run both migrations)

Existing users publish and run migrations to pick it up; skipping it is safe — everything works without the index, just slower at scale.

Testing

New test running the upgrade migration and asserting the index exists. Full suite: 43 passed (173 assertions), PHPStan level 8 clean, Pint clean.

Pruning (WHERE created_at <= ?) and recent-first browsing queries were
scanning the table, which grows by design. Adds the index to the create
stub for new installs plus an upgrade migration guarded with hasIndex so
it is a no-op where the index already exists.
@craigpotter
craigpotter merged commit dd498e4 into main Jul 18, 2026
10 checks passed
@craigpotter
craigpotter deleted the fix/created-at-index branch July 18, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant