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.
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:
-
- 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 aUser
. A singleUser
can have multipleAccount
, but eachAccount
can only have oneUser
. - Session: The
Session
model is used for database sessions and it can store arbitrary data for an active user session. A singleUser
can have multipleSession
, each Session can only have oneUser
. - VerificationToken: The
VerificationToken
model is used to temporary tokens (used for magic-link login).
- User: The
-
Tables handled by TurboStack
- Project: The
Project
model is for information about projects associated with aUser
. A singleUser
can have multipleProject
, and a singleProject
can have multipleUser
. - ProjectUser: The
ProjectUser
model is for information about the relation between anUser
and aProject
. - ProjectInvite: The
ProjectInvite
model is for information about the invites created for aProject
. A singleProject
can have multipleProjectInvite
, but eachProjectInvite
can only have oneProject
.
- Project: The
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:
It automagically creates a new .sql
migration file, with all the changes applied to the schema.