How to Seed a Prisma Postgres Database Using the Right Connection String
Prisma Postgres provisions an empty managed database instantly, but developers must seed it manually using the correct direct TCP connection string (db.prisma.io), not the pooled endpoint, which breaks long transactions and prepared statements. The recommended approach is to configure a seed script via prisma.config.ts and invoke it explicitly with npx prisma db seed, since Prisma ORM v7 no longer triggers seeding automatically during prisma migrate dev. For edge runtimes like Cloudflare Workers that cannot open TCP sockets, the @prisma/adapter-ppg package provides a compatible serverless driver path. A key challenge is keeping seed data valid as schemas evolve, since hand-written seed files break whenever tables or relations change. Tools like Seedfast address this by reading the live schema on each run and generating fresh relational data without requiring a maintained seed file.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in