Drizzle ORM + Neon Postgres Skill
This skill dictates how to interact with the PostgreSQL database using Drizzle ORM and Neon.
Core Directives
- •Connection: Use
@neondatabase/serverlesswith Drizzle'sneonconnector to interact with the Neon Postgres database over HTTP/WebSockets. EnsureDATABASE_URLis used from the environment. - •Schema Definition: Define schemas explicitly in
schema.ts(or under adb/schema/directory). Export all tables and relations. Use appropriate PostgreSQL types (e.g.,varchar,timestamp,uuid,jsonb). - •Relations: Define relations explicitly using Drizzle's
relationsAPI (e.g., one-to-many, many-to-many) to enable relational queries. - •Querying: Prefer Drizzle's relational query API (
db.query...) for nested data fetches, and standard SQL-like API (db.select().from()) for flat queries or aggregations. - •Migrations: Manage migrations using
drizzle-kit. Rundrizzle-kit generateto create SQL migration files anddrizzle-kit push(for prototyping) or run the migrator script for production. Ensuredrizzle.config.tsis properly configured with the Neon connection string.