TurboKit
Database

Schema

Prisma database schema

Database Schema

TurboKit includes a starter schema with user authentication models.

Entity Relationship Diagram

erDiagram
    User ||--o{ Account : "has"
    User ||--o{ Session : "has"

    User {
        String id PK
        String email UK
        String name
        String password
        String avatar
        Role role
        DateTime emailVerified
        DateTime createdAt
        DateTime updatedAt
    }

    Account {
        String id PK
        String userId FK
        String type
        String provider
        String providerAccountId
    }

    Session {
        String id PK
        String sessionToken UK
        String userId FK
        DateTime expires
    }

Schema File

Located at packages/database/prisma/schema.prisma:

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id            String    @id @default(cuid())
  email         String    @unique
  name          String?
  password      String?
  avatar        String?
  role          Role      @default(USER)
  emailVerified DateTime?

  accounts      Account[]
  sessions      Session[]

  createdAt     DateTime  @default(now())
  updatedAt     DateTime  @updatedAt

  @@map("users")
}

model Account {
  id                String  @id @default(cuid())
  userId            String
  type              String
  provider          String
  providerAccountId String

  user User @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@unique([provider, providerAccountId])
  @@map("accounts")
}

model Session {
  id           String   @id @default(cuid())
  sessionToken String   @unique
  userId       String
  expires      DateTime

  user         User     @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@map("sessions")
}

enum Role {
  USER
  ADMIN
  SUPER_ADMIN
}

Models

User

FieldTypeDescription
idStringUnique identifier (CUID)
emailStringUnique email address
nameString?Display name
passwordString?Hashed password
roleRoleUser role (USER, ADMIN, SUPER_ADMIN)
emailVerifiedDateTime?Email verification timestamp

Account

OAuth/social login accounts linked to users.

Session

Active user sessions for session-based auth.

Extending the Schema

Add new models to the schema:

model Post {
  id        String   @id @default(cuid())
  title     String
  content   String?
  published Boolean  @default(false)
  authorId  String
  author    User     @relation(fields: [authorId], references: [id])
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  @@map("posts")
}

Then run:

bun run db:push
bun run db:generate

On this page