Database & ORM Skill
Core Principles
- N+1 is the silent killer: Always eager-load when fetching related data.
- No HTTP calls inside transactions: Transactions must be short-lived (< 100ms).
- Migrations are code: Review them, test them, version them.
- Select only needed columns:
SELECT *wastes bandwidth and memory. - Batch operations:
insertManyinstead of Ninsertcalls in a loop.
References
references/drizzle-patterns.md— Schema, queries, relations, migrations, prepared statementsreferences/prisma-patterns.md— Schema design, client singleton, middleware, migrationsreferences/prisma-performance.md— N+1 prevention, transactions, raw queries, query loggingreferences/migration-strategies.md— Zero-downtime, expand-contract, column rename, NOT NULL constraintreferences/migration-safety.md— Data backfill patterns, rollback strategies, migration testing, pre-migration checklist