Skip to main content
ProStack uses PostgreSQL as its database and Prisma as the ORM (Object-Relational Mapping) tool for database operations.

Database Setup

Before you can use the database, make sure you have:
  1. Installed PostgreSQL on your system
  2. Created a database for your application
  3. Updated the DATABASE_URL in your .env file

Prisma Schema

The Prisma schema defines your database models and relationships. In ProStack, the schema is located in prisma/schema.prisma.
When you modify the schema, you need to synchronize these changes with your database.

Database Commands

ProStack includes several commands to manage your database:

Working with Prisma Client

ProStack provides a configured Prisma client in lib/db.ts that you can import and use in your application:

Database Relationships

Prisma makes it easy to work with relationships between tables. For example, to fetch a user with their posts:

Using Transactions

For operations that require multiple database changes, use transactions to ensure data consistency:

Database Migrations

In production environments, it’s recommended to use migrations instead of db push:
  1. Create a migration:
  1. Apply migrations in production:

Docker Database Setup

If you’re using Docker for development, update your DATABASE_URL in the .env.docker file:

Next Steps

Docker Deployment

Deploy your application using Docker

Authentication

Learn about the authentication system