> ## Documentation Index
> Fetch the complete documentation index at: https://docs.turbostack.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Database

> At the end of this tutorial, you'll have your database up and running

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

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

If you want the Database Provider, you can achieve this following the [prisma documentation](https://www.prisma.io/docs/orm/overview/databases).

## Database Schema

Here's an image of the database schema:

<img src="https://mintcdn.com/ravitechsolutions/jCk1IPeJr8ul3nyO/images/schema.svg?fit=max&auto=format&n=jCk1IPeJr8ul3nyO&q=85&s=77c0629ae1a150c8f5c7dc2b3909cfc5" alt="Database Schema" width="947" height="1157" data-path="images/schema.svg" />

This schema can be segmented by two sections:

* [**Tables handled by NextAuth**](https://authjs.dev/concepts/database-models)
  * **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:

```bash theme={null}
pnpm --filter web prisma:migrate
```

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