Skip to content

Add Prisma/Postgres moderation backend with DB client, schema and migrations#363

Open
smcga wants to merge 3 commits intomainfrom
codex/evaluate-appropriateness-of-redis-datastore
Open

Add Prisma/Postgres moderation backend with DB client, schema and migrations#363
smcga wants to merge 3 commits intomainfrom
codex/evaluate-appropriateness-of-redis-datastore

Conversation

@smcga
Copy link
Copy Markdown
Owner

@smcga smcga commented Apr 9, 2026

Motivation

  • Provide a durable moderation-backed store for doodles and generated effects using Prisma/Postgres while preserving the existing Upstash KV fallback.
  • Allow deployments to opt into Postgres via standard env vars with clear precedence and trimmed values.
  • Ship a local migration and generation workflow so production moderation data can be managed with prisma tools.

Description

  • Add api/db.ts implementing getDatabaseUrl and createDbClient with env var normalization, precedence, and a cached global Prisma client instance.
  • Persist moderation records by updating api/doodles.ts and api/effects.ts to read/create/update pending and approved items via dbClient when available and to gracefully fall back to the existing KV logic.
  • Add Prisma schema (prisma/schema.prisma), initial migration SQL (prisma/migrations/.../migration.sql), and migration lock file, plus package.json scripts prisma:generate and prisma:migrate:dev and dependencies (prisma, @prisma/client).
  • Add unit tests api/db.test.ts for getDatabaseUrl, update README.md to document Prisma/Postgres setup, and update package-lock.json to include new packages.

Testing

  • Ran the unit test suite with vitest (npm run test), including api/db.test.ts, and the tests passed.

Codex Task

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
codexperimental Ready Ready Preview, Comment Apr 9, 2026 7:35am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant