TurboStack uses SQLite as Database by default. All the data will be stored in a dev.db file inside apps/web/prisma folder.

We do not recommend to use SQLite as a database in production. SQLite was determined by default for development purposes and enhances development experience.

If you want the Database Provider, you can achieve this following the prisma documentation.

Database Schema

Here’s an image of the database schema:

This schema can be segmented by two sections:

  • Tables handled by NextAuth

    • User: The User model is for retrieved information from authentication provider (name, email, image)
    • Account: The Account model is for information about accounts associated with a User. A single User can have multiple Account, but each Account can only have one User.
    • Session: The Session model is used for database sessions and it can store arbitrary data for an active user session. A single User can have multiple Session, each Session can only have one User.
    • VerificationToken: The VerificationToken model is used to temporary tokens (used for magic-link login).
  • Tables handled by TurboStack

    • Project: The Project model is for information about projects associated with a User. A single User can have multiple Project, and a single Project can have multiple User.
    • ProjectUser: The ProjectUser model is for information about the relation between an User and a Project.
    • ProjectInvite: The ProjectInvite model is for information about the invites created for a Project. A single Project can have multiple ProjectInvite, but each ProjectInvite can only have one Project.

Migrations

Migrations are controlled sets of changes developed to modify the structure of tables within a database.

Migrations help transition database schemas from their current state to a new desired state, whether that involves adding tables and columns, removing elements, splitting fields, or changing types and constraints.

All migrations are stored in the source code and help you and your team keep track of all the changes made to your database.

Adding new migrations

When you change your schema.prisma file and runs the following command:

pnpm --filter web prisma:migrate

It automagically creates a new .sql migration file, with all the changes applied to the schema.