Skip to content

Feature: refactor/db-integrity-a to dev - #611

Merged
aamoghS merged 3 commits into
devfrom
refactor/db-integrity-a
Nov 14, 2026
Merged

aamoghS merged 3 commits into
devfrom
refactor/db-integrity-a

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Automated PR tracking changes from refactor/db-integrity-a into dev.


Note

Medium Risk
Touches concurrency-sensitive capacity paths (event QR check-in, team joins, hackathon acceptance); behavior should be more correct but needs the new Postgres integration tests and careful review of hot paths.

Overview
Replaces stored counters (events.current_check_ins, hackathons.current_participants, hackathon_teams.current_members) with counts computed from child rows, fixing drift when cascades deleted rows but left counters stale.

A new derived-counts service batches grouped count(*) queries and with*Counts merge helpers so list/get APIs still expose the same field names. Event check-in, hackathon seat checks (assertSeats), and team join/leave now lock parent rows and compare limits to live row counts instead of incrementing/decrementing columns; syncCurrentParticipants and counter updates on undo/reject/withdraw are removed. The public /events page and bootcamp admin sessions use the same helpers.

CI sets TEST_DATABASE_URL so derived-counts.db.test.ts can assert routers honor row counts when stored columns are wrong. Docs, seeds, and existing mocked tests are updated accordingly; schema columns remain for a later drop, with some redundant DB indexes trimmed.

Reviewed by Cursor Bugbot for commit 751460e. Bugbot is set up for automated code reviews on this repo. Configure here.

aamoghS and others added 3 commits November 14, 2026 11:39
Each was a single-column index on the leading column of a unique index or
constraint on the same table, which already serves those lookups. They only
added a write per insert and update.
event.current_check_ins, hackathon_team.current_members and
hackathon.current_participants were running counters. FK cascades (deleting
a user, deleting a team) removed the rows they counted without touching
them, so they drifted and the capacity checks that read them could refuse
real people. Capacity checks now count the child rows under the same
parent-row lock, and every read derives the number with one grouped query
per list. joinTeam now takes that lock too.

The columns stay, unread and unwritten, until a later change drops them.
A real-database test (gated on TEST_DATABASE_URL, set in CI) sets the
stored counters wrong on purpose and checks every count follows the rows.
@github-actions
github-actions Bot requested a review from aamoghS as a code owner November 14, 2026 22:15
@aamoghS aamoghS closed this Nov 14, 2026
@aamoghS aamoghS reopened this Nov 14, 2026
@github-actions github-actions Bot added the dependencies Pull requests that update a dependency file label Nov 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor Author

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions

Copy link
Copy Markdown
Contributor Author

Visit the preview URL for this PR (updated for commit 751460e):

https://hacklyticss2026--pr-611-awnnv4yp.web.app

(expires Sat, 21 Nov 2026 22:18:18 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 5d238be33273095766c18a8339b7b0c47de8a950

@github-actions

Copy link
Copy Markdown
Contributor Author

Visit the preview URL for this PR (updated for commit 751460e):

https://hacklytics2027--pr-611-e0ljvkq7.web.app

(expires Sat, 21 Nov 2026 22:18:17 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: c48ba34db61581e25fe2978355160b5eefe0e83f

@aamoghS
aamoghS merged commit 647dff0 into dev Nov 14, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⤵️ pull dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant