Repository navigation
Feature: refactor/db-integrity-a to dev - #611
Merged
Merged
Conversation
Sync: dev to main
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.
Contributor
Author
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
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 |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automated PR tracking changes from
refactor/db-integrity-aintodev.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-countsservice batches groupedcount(*)queries andwith*Countsmerge 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;syncCurrentParticipantsand counter updates on undo/reject/withdraw are removed. The public/eventspage and bootcamp admin sessions use the same helpers.CI sets
TEST_DATABASE_URLsoderived-counts.db.test.tscan 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.