Agent skill · practicalswan
netlify-database
Zero-config Postgres for Netlify apps via @netlify/database — querying data from Functions/Edge Functions, writing schema migrations, setting up Drizzle ORM, local dev with netlify dev, database branches for deploy previews, and migrating an existing Postgres project onto Netlify. Use when adding a database, building a contact form or CRUD API, writing SQL migrations, wiring up Drizzle, running netlify database commands, testing with a local Postgres, or switching from Neon/Supabase/RDS to Netlify Database.
What it needs
About 10k tokens when loaded.
What this skill does
Netlify Database Zero-config managed Postgres. Install @netlify/database, write migrations under netlify/database/migrations/, deploy — Netlify provisions the DB and applies migrations automatically. Queryable from Functions, Edge Functions, Builds, and Agent Runners. Modern client (reach for this) Own driver / ORM instead: Legacy — do NOT use for new code: import { neon } from "@netlify/neon". Superseded by @netlify/database. Replace neon() calls with the Drizzle netlify-db adapter or a Postgres driver via getConnectionString(). The legacy env var NETLIFYDATABASEURL is replaced by NETLIFYDBURL. Where things go What Location ------ ---------- Migrations netlify/database/migrations/ (SQL files or subdirs with migration.sql) Query code Functions (netlify/functions/), Edge Functions Drizzle schema db/schema.ts (convention) Drizzle client db/index.ts (convention) Connection string NETLIFYDBURL env var, or getConnectionString() Querying getDatabase(options?) returns a client with sql and pool. options.connectionString overrides the auto-provisioned one; options.debug enables logging. SQLTemplate methods: execute() → Promise<T[]>, stream() → AsyncGenerator<T>, chunked(n) → AsyncGenerator<T[]>, toSQL() → raw SQL + params without executing. sql helpers: sql.identifier(value) — safe table/column name. String, string[], or { schema, table, column, as }. sql.values(rows) — bulk-insert values list from a 2D array. sql.default — the SQL DEFAULT keyword. sql.raw(value) — injects unparameterized SQL; bypasses injection protection. Only for trusted constants (e.g. "DESC"), never user input. sql.unsafe(query, params?, { rowMode }) — raw query string with $1 params; rowMode is "array" or "object". Transactions — use pool db.pool is a pg.Pool. BEGIN/queries/COMMIT must run on the same connection: Own drivers: Drizzle ORM Install both packages from @beta — required. latest lacks the drizzle-orm/netlify-db adapter and will fail. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills practicalswan/netlify-database