2026-05-27backend
Unified DB under single Prisma client; raw `postgres` package removed
- Change: All post table queries (
app/lib/actions.ts,app/lib/mutations.ts,app/lib/post-actions.ts) migrated from the rawpostgrestagged-template client to Prisma.lib/db.tsdeleted.postgrespackage removed.prisma/schema.prismaupdated with a correctPostmodel (@@map("posts")) includingmusic_url; stale auto-introspectedpostsandusersmodels removed.ensurePostsTable()runtime table-creation hack removed — schema is now managed by the Prisma model definition.searchPostsretains a singleprisma.$queryRawcall for its ILIKE ranking query, which cannot be expressed through the Prisma query builder. - Why: The raw
postgresclient was only present because Prisma was introduced later (for Better Auth). Keeping two clients added cognitive overhead with no benefit once Prisma was already a required dependency. - Affected Modules:
app/lib/actions.ts,app/lib/mutations.ts,app/lib/post-actions.ts,prisma/schema.prisma,lib/db.ts(deleted),package.json - Trade-offs:
- Pro: Single DB client and pattern throughout the codebase; Prisma-level type safety for all post CRUD; removes the runtime
CREATE TABLE IF NOT EXISTShack. - Con:
searchPostsstill requires$queryRawfor complex ILIKE ranking; Prisma adds a thin ORM layer over what was previously direct SQL.
- Pro: Single DB client and pattern throughout the codebase; Prisma-level type safety for all post CRUD; removes the runtime