netlify-database

Provision and query managed Postgres on Netlify with migrations, Drizzle ORM, and deploy-preview branches.

Updated May 19, 2026
One-click install
npx skills add https://github.com/costrict-plugins-repo/anthropic-netlify-skills --skill netlify-database-costrict-plugins-repo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: netlify-database
Source: https://github.com/costrict-plugins-repo/anthropic-netlify-skills/tree/main/codex/skills/netlify-database
Command: npx skills add https://github.com/costrict-plugins-repo/anthropic-netlify-skills --skill netlify-database-costrict-plugins-repo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @netlify/database, drizzle-orm, drizzle-kit, @netlify/database-dev, @netlify/dev, and includes references (resource) components.

What problem does it solve? Setting up and operating a Postgres database for a Netlify app involves provisioning, connection management, schema migrations, and environment-specific branching. This Skill provides the exact commands, code patterns, and safety rules for Netlify Database so agents and developers configure it correctly without searching documentation. ## Core Features & Use Cases - Zero-config Postgres client: Query with getDatabase() from @netlify/database using auto-parameterized SQL templates, streaming, transactions via pg.Pool, or bring your own driver with getConnectionString(). - Migration workflow: Write SQL migrations in netlify/database/migrations/ or generate them with Drizzle Kit; Netlify applies them automatically on deploy previews and production publishes. - Drizzle ORM integration: Set up the drizzle-orm/netlify-db adapter, configure drizzle.config.ts output to the Netlify migrations directory, and avoid the drizzle-kit push/migrate footguns. - Use Case: Build a CRUD API for a contact form — run netlify database init, define a Drizzle schema, generate a migration, write a Netlify Function that inserts and reads rows, test locally with netlify dev, and deploy with an isolated preview database branch. ## Quick Start Ask the agent to set up Netlify Database in my project with a users table, a Drizzle schema, and a serverless function that reads and writes rows.

Frequently Asked Questions about netlify-database

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a Postgres database to a Netlify project?

Run `netlify database init` to install `@netlify/database`, scaffold a migration, and configure Drizzle or raw SQL. Netlify auto-provisions the database on deploy only if the package is installed; otherwise create it manually from the UI Database menu.

How do I run schema migrations on Netlify Database?

Place SQL files in `netlify/database/migrations/` with timestamp-prefixed names; Netlify applies them automatically on deploy previews and production publishes. Locally, run `netlify database migrations apply` — never run `drizzle-kit push` or `drizzle-kit migrate` against a hosted database.

Does Netlify Database work with Drizzle ORM?

Yes, via the native `drizzle-orm/netlify-db` adapter, which auto-configures the connection. You must install `drizzle-orm` and `drizzle-kit` from `@beta` and set `out` in `drizzle.config.ts` to `netlify/database/migrations` so generated migrations are applied on deploy.

What is the difference between @netlify/database and @netlify/neon?

`@netlify/neon` is the deprecated legacy extension using `NETLIFY_DATABASE_URL`; `@netlify/database` is the GA product using `NETLIFY_DB_URL`. Do not mix them in one project, and migrate legacy projects using the documented three-phase switch process.

Why does getDatabase() throw 'Environment not configured'?

This happens when running outside Netlify, in Functions Lambda compatibility mode, or with an outdated CLI, because no connection string can be resolved. Fix it by passing `connectionString` explicitly to `getDatabase({ connectionString })`.

Can I test Netlify Database locally without deploying?

Yes. `netlify dev` starts a local Postgres-compatible instance, and `@netlify/database-dev` provides a `NetlifyDB` class for unit tests that starts a bare Postgres and applies your migration files. Local is a single database; branches exist only at deploy time.