codefloe/forgejo-codefloe
Watch
4
12
Fork
You've already forked forgejo-codefloe
0

feat(migrations): add composite indexes to issue and issue_label #63

Merged
pat-s merged 1 commit from t3code/issue-composite-indexes into v16.0/forgejo-codefloe 2026-07-29 09:04:13 +00:00
Owner

Addresses the Missing Composite Indexes item (SQL Handling, P1) of #19.

The upstream issue and issue_label tables only declare single-column indexes, so the hot issue-list query patterns cannot be served by one index:

  • filtering issues by repo + open/closed state, ordered by creation time
  • filtering issues by repo + pull/issue + open/closed state
  • joining issues to their labels

Approach: fork-safe

This lands as a fork-owned codefloe_migrations migration (v9.go), not as edits to the upstream model structs. It touches no upstream file, so it cannot conflict with future upstream merges. x.Sync is additive: it creates the named composite indexes if missing and leaves every existing column and index untouched.

Indexes created:

  • issue(repo_id, is_closed, created_unix)
  • issue(repo_id, is_pull, is_closed)
  • issue_label(issue_id, label_id)

Verification

  • Test_AddIssueCompositeIndexes starts from an upstream-shaped table (single-column indexes only), runs the migration, and asserts all three composite indexes exist; it also re-runs the sync to confirm idempotency.
  • Full codefloe_migrations suite green on sqlite.

Closes the composite-index checkbox in #19.

Addresses the **Missing Composite Indexes** item (SQL Handling, P1) of #19. The upstream `issue` and `issue_label` tables only declare single-column indexes, so the hot issue-list query patterns cannot be served by one index: - filtering issues by repo + open/closed state, ordered by creation time - filtering issues by repo + pull/issue + open/closed state - joining issues to their labels ## Approach: fork-safe This lands as a **fork-owned `codefloe_migrations` migration** (`v9.go`), not as edits to the upstream model structs. It touches no upstream file, so it cannot conflict with future upstream merges. `x.Sync` is additive: it creates the named composite indexes if missing and leaves every existing column and index untouched. Indexes created: - `issue(repo_id, is_closed, created_unix)` - `issue(repo_id, is_pull, is_closed)` - `issue_label(issue_id, label_id)` ## Verification - `Test_AddIssueCompositeIndexes` starts from an upstream-shaped table (single-column indexes only), runs the migration, and asserts all three composite indexes exist; it also re-runs the sync to confirm idempotency. - Full `codefloe_migrations` suite green on sqlite. Closes the composite-index checkbox in #19.
pat-s force-pushed t3code/issue-composite-indexes from 5505acf954
Some checks failed
testing / backend-checks (pull_request) Has been cancelled
testing / frontend-checks (pull_request) Has been cancelled
testing / test-unit (pull_request) Has been cancelled
testing / test-e2e (pull_request) Has been cancelled
testing / test-remote-cacher (redis) (pull_request) Has been cancelled
testing / test-remote-cacher (valkey) (pull_request) Has been cancelled
testing / test-remote-cacher (garnet) (pull_request) Has been cancelled
testing / test-mysql (pull_request) Has been cancelled
testing / test-pgsql (pull_request) Has been cancelled
testing / test-sqlite (pull_request) Has been cancelled
to 5de065ff26
All checks were successful
testing / backend-checks (pull_request) Successful in 8m14s
testing / frontend-checks (pull_request) Successful in 1m16s
testing / test-unit (pull_request) Successful in 7m34s
testing / test-e2e (pull_request) Successful in 24m20s
testing / test-remote-cacher (redis) (pull_request) Successful in 1m24s
testing / test-mysql (pull_request) Successful in 31m51s
testing / test-remote-cacher (valkey) (pull_request) Successful in 1m17s
testing / test-sqlite (pull_request) Successful in 54m8s
testing / test-remote-cacher (garnet) (pull_request) Successful in 1m17s
testing / test-pgsql (pull_request) Successful in 55m50s
2026-07-28 14:21:25 +00:00
Compare
pat-s scheduled this pull request to auto merge when all checks succeed 2026-07-28 14:42:31 +00:00
pat-s force-pushed t3code/issue-composite-indexes from 5de065ff26
All checks were successful
testing / backend-checks (pull_request) Successful in 8m14s
testing / frontend-checks (pull_request) Successful in 1m16s
testing / test-unit (pull_request) Successful in 7m34s
testing / test-e2e (pull_request) Successful in 24m20s
testing / test-remote-cacher (redis) (pull_request) Successful in 1m24s
testing / test-mysql (pull_request) Successful in 31m51s
testing / test-remote-cacher (valkey) (pull_request) Successful in 1m17s
testing / test-sqlite (pull_request) Successful in 54m8s
testing / test-remote-cacher (garnet) (pull_request) Successful in 1m17s
testing / test-pgsql (pull_request) Successful in 55m50s
to 848f84d9e1
All checks were successful
testing / frontend-checks (pull_request) Successful in 1m13s
testing / backend-checks (pull_request) Successful in 10m29s
testing / test-unit (pull_request) Successful in 9m24s
testing / test-remote-cacher (garnet) (pull_request) Successful in 1m18s
testing / test-e2e (pull_request) Successful in 29m12s
testing / test-remote-cacher (redis) (pull_request) Successful in 1m32s
testing / test-remote-cacher (valkey) (pull_request) Successful in 1m24s
testing / test-mysql (pull_request) Successful in 31m34s
testing / test-sqlite (pull_request) Successful in 48m20s
issue-labels / backporting (pull_request_target) Has been skipped
testing / test-pgsql (pull_request) Successful in 43m44s
milestone / set (pull_request_target) Has been skipped
2026-07-29 06:27:11 +00:00
Compare
pat-s merged commit e66ff3683f into v16.0/forgejo-codefloe 2026-07-29 09:04:13 +00:00
pat-s deleted branch t3code/issue-composite-indexes 2026-07-29 09:04:14 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
codefloe/forgejo-codefloe!63
No description provided.