Skip to content

Database

Prisma on PostgreSQL, MySQL or MongoDB, with a schema folder per module.

Requires:Works on its own

Providers

Pick one to update the preview and files

Preview

Database

  • prisma/schema.prismagenerator + datasource only
  • prisma/schema/auth.prismaUser, Session, Account, Verification
  • prisma/schema/payments.prismaCustomer, Subscription
  • prisma/schema/storage.prismaStoredFile
  • prisma/schema/ai.prismaAiThread, AiMessage

What it adds

7 things, working end to end
  • Prisma as the only ORM, with a db singleton in lib/db
  • prisma/schema.prisma holds the generator and datasource only: each module adds its models in prisma/schema/<module>.prisma
  • prisma.config.ts pointing at the schema folder
  • A seed script (prisma/seed.ts)
  • Connection pool settings from environment variables
  • MongoDB adds a small lib/db/utils.ts for its differences
  • Migration and schema rules written for coding agents

Set up PostgreSQL

Accounts and keys, in this order
  1. 1
    Get a databaseUse a hosted Postgres or a local container.Your hostCreate database
  2. 2
    Copy the connection stringAdd ?sslmode=require for hosted databases.
    .env
    DATABASE_URL="postgresql://user:password@host:5432/dbname"
    DATABASE_POOL_SIZE=10
    DATABASE_POOL_TIMEOUT=20
  3. 3
    Create the tablesPush the Prisma schema, then start the app.
    npx prisma db push

Environment variables

For the selected provider
.env
# Connection string of your database
DATABASE_URL=
# Connection pool size (optional)
DATABASE_POOL_SIZE=
# Pool timeout in seconds (optional)
DATABASE_POOL_TIMEOUT=

Works with

Other modules this one connects to

Add it to your repo

Pick the preset in the builder, check the providers, and download a repo that already has this module wired in.

Build your repo