Overview
Learn how to use the database in supastarter.
With supastarter you can choose between Prisma and Drizzle as your database ORM.
You can find the schema and configuration in the packages/database
directory either in the prisma
or drizzle
folder.
Configure the ORM
Prisma
You can skip this if you are using Prisma with PostgreSQL, as this is the default setup.
If you are using a different database than PostgreSQL, you will need to configure the database provider in the /packages/database/prisma/schema.prisma
file.
You will also need to change the database provider in the /packages/auth/auth.ts
file:
In case you are using MySQL, you will also need to remove all occurrences of mode: "insensitive"
from the project. This is a feature that Prisma does not support for MySQL, so it will cause errors on build.
Simply search in the project for mode: "insensitive"
and remove it.
Drizzle
If you want to use Drizzle instead of Prisma, you will need to change the export in the /packages/database/index.ts
file:
Next make sure to use the drizzle adapter in the /packages/auth/auth.ts
file:
If you are using a different database than PostgreSQL, you will need to export the schema for either mysql
or sqlite
from the /packages/database/drizzle/schemaindex].ts
file.
Lastly, you will need to set up the correct database client in the client.ts
file. Follow the instructions in the Drizzle documentation for the database provider you are using. For PostgreSQL you can use the following example: