Skip to main content

Database


The API communicates with a PostgreSQL database using Prisma.

We highly recommend consulting the Prisma documentation for a comprehensive understanding of its functionalities.

Configuration

All database-related code resides in the src/core/database folder.

  • database is the protected Prisma instance that apply your authorization rules.
  • unprotectedDatabase is the unprotected Prisma instance, use it only when you have to!

Migrations

In the development environment, the database schema is automatically synchronized, requiring no manual intervention. However, for other environments, SQL migrations need to be generated and executed.

  1. Update your .env file with your production url.
SERVER_DATABASE_URL=your-production-url
  1. Generate migration files
pnpm run --filter server database:migration:build
info

Prisma compares the differences between your codebase entities and the target database schema, creating and storing an SQL script in the prisma/migrations folder.

  1. Run migrations files on the target database
pnpm run --filter server database:migration:run

Database studio

pnpm run database:studio
https://localhost:5000