FeaturesDatabase & Prisma

Database & Prisma

Prisma 7 with multi-database support — PostgreSQL, MySQL, SQLite, SQL Server, and Cloudflare D1 — and a safe schema-partials workflow.

Overview

SiteKnock's data layer is built on Prisma 7. You choose your database engine in config, define your models in schema partials, and the generator assembles everything for you.

Supported databases

ProviderBest for
PostgreSQLProduction (recommended)
MySQL / MariaDBMySQL 8+ / MariaDB 10.6+
SQLiteLocal development and testing
SQL ServerMicrosoft SQL Server environments
Cloudflare D1Edge deployments

Choose a provider

"features": {
  "database": {
    "enabled": true,
    "provider": "postgres"
  }
}

Switch providers at any time:

pnpm db:select -- mysql
pnpm sk:generate

Schema partials

Never edit schema.prisma directly — it's generated. Define your models in .prisma.part partials instead, and the generator merges them with the base schema and enabled feature models.

Partials live under your backend app:

apps/backend/prisma/
├── schema.prisma            # GENERATED — do not edit
└── partials/
    ├── auth.prisma.part     # auth models (from the auth feature)
    ├── orgs.prisma.part     # organization models
    ├── billing.prisma.part  # billing models
    └── custom.prisma.part   # your models

Add a model

  1. Add it to a .prisma.part file:

    model Article {
      id        String   @id @default(cuid())
      title     String
      content   String?
      createdAt DateTime @default(now())
      updatedAt DateTime @updatedAt
    }
    
  2. Generate the client and run a migration for your backend app:

    pnpm app db generate my-app
    pnpm app db migrate my-app
    

Everyday database commands

These run from your project root and target a backend app:

CommandWhat it does
pnpm app db generate <app>Generate the Prisma client
pnpm app db migrate <app>Create and apply a migration
pnpm app db seed <app>Seed demo data
pnpm app db studio <app>Open Prisma Studio to browse data
pnpm app db reset <app>Reset the database (destructive)

Frontend never touches the database

The frontend never imports Prisma. It calls your /api/* routes, which handle all database access server-side. This keeps credentials and queries on the backend where they belong.

Next steps