Skip to content

Sync: dev to main - #616

Merged
aamoghS merged 5 commits into
mainfrom
dev
Nov 14, 2026
Merged

aamoghS merged 5 commits into
mainfrom
dev

Conversation

@github-actions

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

Copy link
Copy Markdown
Contributor

Automated PR tracking changes from dev into main.


Note

Medium Risk
Schema migrations add constraints and a case-insensitive email unique index; deploy can fail if existing rows violate the new rules or duplicate emails differ only by case.

Overview
Adds database-level validation across auth, events, hackathons, judging, and points schemas so invalid writes fail at Postgres, not only in the API.

On user, a new uniqueIndex on lower(email) enforces one account per address regardless of casing—aligned with the auth adapter’s case-insensitive lookups.

CHECK constraints now guard date/time ordering (end ≥ start), positive caps (maxCheckIns, maxParticipants, maxMembers), non-negative points/prices/stock, judging schedule windows and non-negative slot minutes, appointment time ordering (startsAt ≤ deadlineAt ≤ endsAt), rubric ratings 1–5, point adjustment deltas (non-zero, −1000..1000), and store purchase arithmetic (total = unitPrice × quantity, quantity > 0).

In judging, the judging_entry_challenge primary key is declared with an explicit name and column order matching what drizzle-kit reads from Postgres, stopping migrate-push from repeatedly drop/recreate that key on deploy.

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

aamoghS and others added 5 commits November 14, 2026 17:47
user.email gets a unique index (the auth adapter already assumed one row per
address), and 14 CHECK constraints hold ranges the API enforces today:
ratings 1-5, end after start on hackathons, events and judging schedules,
appointment times in order, positive caps, non-negative prices, stock and
points, purchase totals equal to unit price times quantity, and point
adjustments non-zero within -1000..1000.

The production preflight (packages/db/sql/preflight-2026-11-constraints.sql)
found no row breaking any of these. It found one initiative with
max_members = 0, so that check is left out until the row is corrected.
drizzle-kit reads a primary key's columns from constraint_column_usage,
which lists them by name (challenge_id, entry_id), and compared that with the
declared entry-first order. Every deploy's push dropped and re-added the key.
Declare it in the order drizzle-kit reads, under the name it already has;
the key in the database is unchanged.
The auth adapter looks users up by lower(email), and providers keep the
casing an address was typed in, so a unique index on the raw column still
allowed Ada@x.com and ada@x.com as two accounts. Index lower(email) instead,
and keep the plain email index the exact-match lookups use. Production has no
two addresses that collide once lowercased.
@github-actions

Copy link
Copy Markdown
Contributor Author

@greptileai

@aamoghS aamoghS reopened this 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 6381fe1):

https://hacklytics2027--pr-616-8b8cowlr.web.app

(expires Sat, 21 Nov 2026 23:09:52 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: c48ba34db61581e25fe2978355160b5eefe0e83f

@github-actions

Copy link
Copy Markdown
Contributor Author

Visit the preview URL for this PR (updated for commit 6381fe1):

https://hacklyticss2026--pr-616-dbqqyct0.web.app

(expires Sat, 21 Nov 2026 23:09:53 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 5d238be33273095766c18a8339b7b0c47de8a950

@aamoghS
aamoghS merged commit 1452a07 into main Nov 14, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant