Task: Add Database-Level Length Constraints via Prisma #344

Open
opened 2026-02-28 00:12:12 +00:00 by jjalangtry · 0 comments
jjalangtry commented 2026-02-28 00:12:12 +00:00 (Migrated from github.com)

Add Database-Level Length Constraints via Prisma

Description

The Prisma schema uses String type for all text fields with no length annotations. PostgreSQL maps these to TEXT columns with no enforced maximum. Adding @db.VarChar(N) annotations creates a hard DB-level backstop that catches oversized data even if app-layer Zod validation is bypassed (e.g. via direct DB access, future code paths, or migration scripts).

Associated Epic: #340

Subtasks

  • Audit next/prisma/schema.prisma for all String fields and map to the same limits used in Zod schemas (#341):
    • User: name @db.VarChar(100), major @db.VarChar(100), bio @db.VarChar(1000), gitHub @db.VarChar(500), linkedIn @db.VarChar(500)
    • Event: title @db.VarChar(200), description @db.VarChar(2000), location @db.VarChar(300)
    • Quote: quote @db.VarChar(2000), author @db.VarChar(100)
    • GoLink: name @db.VarChar(60), url @db.VarChar(500)
    • Project: title @db.VarChar(200), description @db.VarChar(2000)
    • Sponsor: name @db.VarChar(200), description @db.VarChar(1000), logoUrl @db.VarChar(500), websiteUrl @db.VarChar(500)
    • Alumni / AlumniRequest: name @db.VarChar(100), description @db.VarChar(1000), linkedIn @db.VarChar(500), gitHub @db.VarChar(500)
    • Announcement: message @db.VarChar(500), category @db.VarChar(100)
    • PurchaseRequest: item @db.VarChar(200), vendor @db.VarChar(200), justification @db.VarChar(1000)
  • Run prisma migrate dev to generate and verify the migration
  • Confirm no existing data exceeds the new limits before applying to production (add a pre-migration data audit query)

Acceptance Criteria

  • All free-text fields in the Prisma schema have explicit @db.VarChar(N) annotations
  • A migration file is generated and reviewed
  • Existing data audit confirms no rows would be truncated
  • The limits in schema.prisma exactly match those in the Zod schemas in next/lib/schemas/
# Add Database-Level Length Constraints via Prisma ## Description The Prisma schema uses String type for all text fields with no length annotations. PostgreSQL maps these to TEXT columns with no enforced maximum. Adding @db.VarChar(N) annotations creates a hard DB-level backstop that catches oversized data even if app-layer Zod validation is bypassed (e.g. via direct DB access, future code paths, or migration scripts). Associated Epic: #340 ## Subtasks - [ ] Audit next/prisma/schema.prisma for all String fields and map to the same limits used in Zod schemas (#341): - User: name @db.VarChar(100), major @db.VarChar(100), bio @db.VarChar(1000), gitHub @db.VarChar(500), linkedIn @db.VarChar(500) - Event: title @db.VarChar(200), description @db.VarChar(2000), location @db.VarChar(300) - Quote: quote @db.VarChar(2000), author @db.VarChar(100) - GoLink: name @db.VarChar(60), url @db.VarChar(500) - Project: title @db.VarChar(200), description @db.VarChar(2000) - Sponsor: name @db.VarChar(200), description @db.VarChar(1000), logoUrl @db.VarChar(500), websiteUrl @db.VarChar(500) - Alumni / AlumniRequest: name @db.VarChar(100), description @db.VarChar(1000), linkedIn @db.VarChar(500), gitHub @db.VarChar(500) - Announcement: message @db.VarChar(500), category @db.VarChar(100) - PurchaseRequest: item @db.VarChar(200), vendor @db.VarChar(200), justification @db.VarChar(1000) - [ ] Run prisma migrate dev to generate and verify the migration - [ ] Confirm no existing data exceeds the new limits before applying to production (add a pre-migration data audit query) ## Acceptance Criteria - [ ] All free-text fields in the Prisma schema have explicit @db.VarChar(N) annotations - [ ] A migration file is generated and reviewed - [ ] Existing data audit confirms no rows would be truncated - [ ] The limits in schema.prisma exactly match those in the Zod schemas in next/lib/schemas/
Sign in to join this conversation.
No milestone
No project
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
SSE/WebsiteTheSSEquel#344
No description provided.