Prisma and Database

The parent app uses Prisma with PostgreSQL, and several major product systems rely directly on the schema shape.

Main Database Files

src/lib/prisma.ts uses the standard Prisma singleton pattern to avoid creating too many clients during development.

  • ../jampack-saas-starterkit/prisma/schema.prisma
  • lib/prisma.ts
  • ../jampack-saas-starterkit/package.json

Important Models

Two of the most important design choices are Profile.id matching the Supabase user ID and organization-level billing being stored separately from profile-level billing.

  • Profile
  • Organization
  • OrgMember
  • Team
  • TeamMember
  • Invite
  • Plan
  • Subscription
  • OrganizationSubscription
  • Post
  • Project
  • Task
  • Email
  • Chat
  • Message

Step 1: Generate and Migrate

The project build also runs prisma generate, and postinstall does the same after package installation.

npx prisma generate
npx prisma migrate dev

Step 2: Understand Billing Tables

If billing behaves incorrectly after checkout, these are the first tables to inspect.

  • profiles stores the active user-level billing snapshot.
  • subscriptions stores the Stripe profile subscription details.
  • organizations stores the active organization-level billing snapshot.
  • organization_subscriptions stores the Stripe organization subscription details.

Step 3: Production Migration Command

Run this before turning on app subscriptions in production.

npx prisma migrate deploy

Verification Checklist

  1. Create one user through auth.
  2. Create one organization.
  3. Create one blog post.
  4. Create one project and task.
  5. Run one billing flow and inspect billing tables.