Prisma ORM and PostgreSQL database management for EFT-Tracker. Handles schema design, migrations, client generation, and Neon database branches. Activates when user mentions: database, schema, migration, Prisma, model, relation, PostgreSQL, Neon, db push, db pull.
db push vs migrate)# 1. Modify prisma/schema.prisma
# 2. Push to database (development)
npx prisma db push
# 3. Generate client (if not auto-generated)
npx prisma generate
| Command | Use When |
|---|---|
db push | Development, prototyping, schema iteration |
migrate dev | Production-ready migrations with history |
migrate deploy | CI/CD production deployments |
This project uses db push for development simplicity with Neon branches.
Use separate databases for different workflows:
| Environment | Database | When to Use |
|---|---|---|
| Local dev | Personal dev database | Feature work |
| Development | DATABASE_URL_DEVELOP | Testing develop branch |
| Production | DATABASE_URL | Never use locally |
Critical: Never connect to production database from local development.
Always include these fields on new models:
model Example {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// ... other fields
}
// One-to-many
model User {
id String @id @default(cuid())
posts Post[]
}
model Post {
id String @id @default(cuid())
author User @relation(fields: [authorId], references: [id])
authorId String
}
// Many-to-many (implicit)
model Post {
tags Tag[]
}
model Tag {
posts Post[]
}
Add indexes for frequently queried fields:
model Quest {
id String @id
traderId String
@@index([traderId])
}
Neon uses connection pooling. Use the pooled connection string: