
Drizzle
This is a strict Drizzle ORM style guide for a Postgres project, specifically LobeHub's conventions. It enforces the query builder API over the relational API because those `with:` joins generate fragile lateral queries that are hard to debug. You get concrete patterns for schema authoring: how to name tables and columns, spread timestamps, set up foreign keys with cascade deletes, and build junction tables. The guide is opinionated about splitting one-to-many fetches into two separate queries instead of using `db.query.findMany` with nested relations. If you're on a team that's had production issues with auto-generated joins or needs everyone writing queries the same way, this codifies those decisions.
- skills.sh installs
- 1.4K
- GitHub stars
- 79.8K
- last updated
- Jul 14, 2026
Install
$ npx -y skills add lobehub/lobe-chat --skill drizzle --agent claude-codeInstalls into .claude/skills of the current project.
Files
Drizzle ORM Schema Style Guide
Adding a Model or Repository? Ship a sibling test in the same PR — every new file under
packages/database/src/models/**orsrc/repositories/**needs a matching__tests__/<name>.test.ts. See the testing skill (.agents/skills/testing/references/db-model-test.md) for thegetTestDB()integration pattern, user-isolation tests, the BM25describe.skipIf(!isServerDB)guard, and schema gotchas. CI's coverage patch gate won't reliably catch a brand-new untested file, so this is on you.
Configuration
- Config:
drizzle.config.ts - Schemas:
packages/database/src/schemas/ - Migrations:
packages/database/migrations/ - Dialect:
postgresqlwithstrict: true
Helper Functions
Location: packages/database/src/schemas/_helpers.ts
timestamptz(name): Timestamp with timezonecreatedAt(),updatedAt(),accessedAt(): Standard timestamp columnstimestamps: Object with all three for easy spread
Naming Conventions
Sponsors
Details
- Repository
- github.com/lobehub/lobe-chat
- Categories
- Backend & APIs, Databases
- First seen
- May 16, 2026