Skip to main content

Database


The API communicates with a PostgreSQL database using TypeORM.

We highly recommend consulting the NestJS TypeORM documentation for a comprehensive understanding of its functionality.

Configuration

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

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

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

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

PgAdmin

A PgAdmin instance is accessible at https://localhost:5052.

Authentication

CredentialValue
User emailadmin@admin.com
User passwordroot

Register your server

  1. Right click on Servers, then click on Register > Server...
  1. On Docker Desktop, copy the name of your PostgreSQL service.
  1. Back in PgAdmin, configure your server connection details.
KeyValue
Connection > Host name/addressXXXXXX-<your-slug>-postgresql
Connection > Port5432
Connection > Usernameroot
Connection > Passwordroot
info

Ensure that the Host name/address matches your Docker PostgreSQL service name.