Drizzle
This skill covers Drizzle ORM usage in the `@internal/dashboard-agent-db` package, the agent's dedicated conversation store. Learn schema definition with pg-core, postgres.js driver configuration, drizzle-kit migrations, and the repo's access-pattern query layer enforcing tenant scoping and foreign-key-free design. Drizzle is isolated from the main Prisma database.
Drizzle helps you write and modify ORM schemas and queries for the dashboard agent's conversation datastore.
AI-generated summary based on this skill's SKILL.md
Install
triggerdotdev/trigger.dev/drizzle · repository language: TypeScript
git clone https://github.com/triggerdotdev/trigger.dev
cp -r trigger.dev/.claude/skills/drizzle ~/.claude/skills/drizzleFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do I write drizzle queries for the dashboard agent?
Drizzle queries in the dashboard agent use the `@internal/dashboard-agent-db` package's access-pattern layer. Import table definitions from pg-core schemas, then use Drizzle's select, insert, update, and delete methods. The repo enforces tenant scoping without foreign keys—queries filter by tenant ID at the application level. Use `db.query.tableName.findFirst()` or `db.select().from(table).where()` patterns. Drizzle is isolated from the main Prisma database, so connection setup uses postgres.js directly.
Drizzle migrations postgresql—how do I generate and apply them?
Drizzle migrations use drizzle-kit. Run `drizzle-kit generate migrate` to introspect your pg-core schemas and create SQL migration files. Then apply them with `drizzle-kit migrate` or execute the generated SQL directly against your postgres database. The dashboard agent stores migrations in the `@internal/dashboard-agent-db` package. Ensure your postgres.js connection is pooler-safe by configuring the client with appropriate timeout and connection settings before running migrations.
What's the postgres.js driver drizzle setup for pooler-safe connections?
Drizzle's postgres.js setup requires instantiating a postgres client with pooler-safe options. Pass the connection string to `postgres()`, then wrap it in Drizzle using `drizzle(client)`. For pooler safety, configure idle timeout, statement timeout, and disable prepared statements if using a connection pooler that doesn't support them. The dashboard agent's `@internal/dashboard-agent-db` package handles this configuration. Avoid long-lived connections; let the pooler manage lifecycle.
How does Drizzle handle schema isolation without foreign keys?
Drizzle in the dashboard agent enforces multi-tenant scoped queries without foreign keys. Define tables using `pgSchema()` and `pgTable()` from pg-core, then implement tenant filtering in the access-pattern query layer—not at the database level. Every query must explicitly filter by tenant ID. This design isolates conversation data per tenant and avoids foreign-key constraints. The `@internal/dashboard-agent-db` package provides pre-built queries that enforce this pattern automatically.
What should I know about drizzle prepared statements and pooler compatibility?
Drizzle prepared statements can conflict with connection poolers that don't support them. If you encounter Node16 module resolution or prepared statement errors, disable them in your postgres.js client configuration or use a pooler that supports prepared statements natively. The dashboard agent's setup handles this, but when debugging issues in `@internal/dashboard-agent-db`, check that your postgres.js version (3.4+) and drizzle-orm version (0.45+) are compatible and that pooler settings align with your connection strategy.
How do I define and query jsonb columns in Drizzle schemas?
Drizzle supports jsonb columns via `pgTable()` with the `jsonb()` type from pg-core. Define typed jsonb fields using generics: `jsonb('metadata').$type<MetadataType>()`. Query jsonb data using Drizzle's operators or raw SQL. For the dashboard agent, jsonb stores conversation metadata and agent state. Combine jsonb with soft deletes (timestamp-based) and composite indexes for efficient querying. The `@internal/dashboard-agent-db` package includes example schemas with typed jsonb and index definitions.
SKILL.md
rendered from the published skill — quoted content, verbatim
Drizzle ORM (this repo)
Drizzle is used in exactly one place: internal-packages/dashboard-agent-db (@internal/dashboard-agent-db), the in-dashboard agent's conversation store. Everything else in the monorepo is Prisma (@trigger.dev/database). Keep them separate.
Pinned versions: drizzle-orm ^0.45, drizzle-kit ^0.31 (dev), postgres ^3.4 (postgres.js driver). drizzle-orm and drizzle-kit are intentionally on different version lines — 0.31.x is the correct companion for 0.45.x, there is no peer dependency between them.
Critical rules
- **Drizzle is only the agent's own
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 1 file
.claude/skills/drizzle/SKILL.md