Prerequisites
- PostgreSQL 16 or later
- Node.js ≥ 20
- pnpm package manager
Using Docker Compose
The easiest way to get started is using the included Docker Compose configuration:- Port:
5432 - User:
postgres(configurable viaPOSTGRES_USER) - Password:
postgres(configurable viaPOSTGRES_PASSWORD) - Database:
toots(configurable viaPOSTGRES_DB) - Persistent volume:
db_data
Make sure to set
POSTGRES_USER, POSTGRES_PASSWORD, and POSTGRES_DB in your environment or root .env file before running Docker Compose.Manual PostgreSQL setup
If you prefer to use an existing PostgreSQL instance:- Create a database for Toots:
- Update your
DATABASE_URLinapps/web/.env:
Database schema
Toots uses Prisma for database management. The schema includes:Core models
- User - User accounts with email/password authentication
- Session - User sessions managed by better-auth
- Account - OAuth and credential account information
- Project - Projects with tickets and chat messages
- Ticket - Actionable work items with priority, type, and status
- Message - Project chat history
- Verification - Email verification tokens
Key relationships
Running migrations
After configuring your database connection, run migrations to create the schema:prisma migrate dev, which:
- Creates migration files if the schema changed
- Applies pending migrations to your database
- Generates the Prisma Client
Database scripts
The web app includes several helpful database scripts:Generate Prisma Client
Regenerate the Prisma Client after schema changes:Database push
Push schema changes without creating migration files (useful for prototyping):Prisma Studio
Open Prisma Studio to view and edit database records:http://localhost:5555.
Production deployment
For production builds, migrations are automatically run as part of the build process:package.json
prisma migrate deploy command:
- Applies pending migrations without prompting
- Does not create new migrations
- Suitable for CI/CD pipelines
Connection pooling
Toots uses the@prisma/adapter-pg for connection pooling. This is configured automatically through the Prisma schema:
schema.prisma
pg package for efficient connection management.
Troubleshooting
Migration failed
If a migration fails:- Check your
DATABASE_URLis correct - Ensure the database exists
- Verify PostgreSQL is running
- Check database logs for errors