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 raw postgres tagged-template client to Prisma. lib/db.ts deleted. postgres package removed. prisma/schema.prisma updated with a correct Post model (@@map("posts")) including music_url; stale auto-introspected posts and users models removed. ensurePostsTable() runtime table-creation hack removed — schema is now managed by the Prisma model definition. searchPosts retains a single prisma.$queryRaw call for its ILIKE ranking query, which cannot be expressed through the Prisma query builder.
  • Why: The raw postgres client 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 EXISTS hack.
    • Con: searchPosts still requires $queryRaw for complex ILIKE ranking; Prisma adds a thin ORM layer over what was previously direct SQL.