OpenInvoice uses PostgreSQL with Prisma ORM for database management. This guide covers database setup, migrations, and management.
DATABASE_URL=postgresql://user:password@host:port/database
DATABASE_URL=postgresql://postgres:password@localhost:5432/openinvoice
bun prisma generate
This generates the Prisma Client based on your schema.
bun prisma migrate dev
This creates all database tables and relationships.
If seed data is available:
bun prisma db seed
See prisma/schema.prisma for complete schema.
When schema changes:
bun prisma migrate dev --name migration_name
In production:
bun prisma migrate deploy
⚠️ Warning: This deletes all data!
bun prisma migrate reset
View and edit data visually:
bun prisma studio
Opens at http://localhost:5555
pg_dump -U postgres openinvoice > backup.sql
psql -U postgres openinvoice < backup.sql
Use connection pooling in production: