@netlify/agent-runner-cli 1.103.1 → 1.104.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +64 -62
- package/dist/bin.js +56 -54
- package/dist/index.d.ts +2 -0
- package/dist/index.js +62 -60
- package/dist/skills/netlify-database@netlifydb/SKILL.md +104 -37
- package/package.json +3 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: netlify-database
|
|
3
|
-
description: Use Netlify Database
|
|
3
|
+
description: Use Netlify Database to store application data — records, collections, lists, user data, or any structured information. Provides a fully managed Postgres database. Use for CRUD operations, queryable data, or anything you would naturally model as rows in a table. Use Blobs only for files, binary assets, or cached responses.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Netlify Database
|
|
@@ -8,8 +8,8 @@ description: Use Netlify Database for relational data storage with a fully manag
|
|
|
8
8
|
Netlify Database is a fully managed Postgres database built into the Netlify platform. It handles provisioning, migrations,
|
|
9
9
|
and database branching automatically. There is no setup beyond installing the `@netlify/database` package.
|
|
10
10
|
|
|
11
|
-
Prefer Netlify Database over Netlify Blobs
|
|
12
|
-
|
|
11
|
+
Prefer Netlify Database over Netlify Blobs for any application data — records, collections, lists, user-generated content,
|
|
12
|
+
or anything you would store as rows. Use Blobs only for files, binary assets (images, video), or cached responses.
|
|
13
13
|
|
|
14
14
|
## CRITICAL: Use the `@beta` dist-tag for Drizzle
|
|
15
15
|
|
|
@@ -119,8 +119,7 @@ Run this every time you change the schema:
|
|
|
119
119
|
npx drizzle-kit generate
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
-
This creates SQL migration files in `netlify/database/migrations/`.
|
|
123
|
-
DO NOT create the migrations directory manually — `drizzle-kit generate` creates it.
|
|
122
|
+
This creates SQL migration files in `netlify/database/migrations/`.
|
|
124
123
|
|
|
125
124
|
### Step 6: Use the database in functions
|
|
126
125
|
|
|
@@ -150,17 +149,6 @@ export const config: Config = {
|
|
|
150
149
|
};
|
|
151
150
|
```
|
|
152
151
|
|
|
153
|
-
### Modifying an existing schema
|
|
154
|
-
|
|
155
|
-
When adding columns, tables, or changing the schema in an existing project:
|
|
156
|
-
|
|
157
|
-
1. Update the Drizzle schema definition with your changes
|
|
158
|
-
2. Run `npx drizzle-kit generate` — this is REQUIRED, not optional
|
|
159
|
-
3. Verify new migration files appear in `netlify/database/migrations/`
|
|
160
|
-
4. Update any application code that uses the changed tables
|
|
161
|
-
|
|
162
|
-
Do NOT skip step 2. The database will not reflect your schema changes without a generated migration.
|
|
163
|
-
|
|
164
152
|
### Drizzle ORM query reference
|
|
165
153
|
|
|
166
154
|
```typescript
|
|
@@ -276,15 +264,15 @@ Each migration is a SQL file named `<number>_<slug>.sql`:
|
|
|
276
264
|
|
|
277
265
|
```
|
|
278
266
|
netlify/database/migrations/
|
|
279
|
-
├──
|
|
280
|
-
├──
|
|
281
|
-
└──
|
|
267
|
+
├── 20260417143022_create-users.sql
|
|
268
|
+
├── 20260418091500_add-posts.sql
|
|
269
|
+
└── 20260419112330_create-comments.sql
|
|
282
270
|
```
|
|
283
271
|
|
|
284
272
|
Example migration:
|
|
285
273
|
|
|
286
274
|
```sql
|
|
287
|
-
-- netlify/database/migrations/
|
|
275
|
+
-- netlify/database/migrations/20260417143022_create-users.sql
|
|
288
276
|
CREATE TABLE users (
|
|
289
277
|
id SERIAL PRIMARY KEY,
|
|
290
278
|
name TEXT NOT NULL,
|
|
@@ -297,7 +285,9 @@ Rules for migration names:
|
|
|
297
285
|
- `number` is any sequence of digits (e.g. `001`, `0001`, or a Unix timestamp)
|
|
298
286
|
- `slug` contains only lowercase letters, numbers, hyphens, and underscores
|
|
299
287
|
- Migrations are sorted lexicographically and applied in order
|
|
300
|
-
- NEVER modify a migration
|
|
288
|
+
- NEVER modify a migration file once it has been applied to any database (local, preview, or production).
|
|
289
|
+
Unapplied migration files can be freely deleted and regenerated; see "Iterating on migrations within a
|
|
290
|
+
session" below.
|
|
301
291
|
|
|
302
292
|
## Migrations: how they work
|
|
303
293
|
|
|
@@ -314,10 +304,8 @@ Netlify applies migrations automatically during deploys:
|
|
|
314
304
|
Migrations MUST be in `netlify/database/migrations/` to be applied automatically.
|
|
315
305
|
|
|
316
306
|
Two formats are supported:
|
|
317
|
-
1. SQL files directly in the directory (e.g. `
|
|
318
|
-
2. Subdirectories containing a `migration.sql` file (e.g. `
|
|
319
|
-
|
|
320
|
-
Drizzle Kit generates migrations in the subdirectory format. Both formats can coexist.
|
|
307
|
+
1. SQL files directly in the directory (e.g. `20260417143022_create-users.sql`)
|
|
308
|
+
2. Subdirectories containing a `migration.sql` file (e.g. `20260417143022_create-users/migration.sql`)
|
|
321
309
|
|
|
322
310
|
## Database branches
|
|
323
311
|
|
|
@@ -325,6 +313,92 @@ Drizzle Kit generates migrations in the subdirectory format. Both formats can co
|
|
|
325
313
|
- **Deploy previews** get their own isolated database branch with a copy of production data.
|
|
326
314
|
- Changes in a deploy preview's branch never affect the production database.
|
|
327
315
|
- You do NOT need to do anything to enable branching — it is automatic.
|
|
316
|
+
- A preview branch persists across multiple runs in the same session. Migrations you applied in an earlier run
|
|
317
|
+
remain applied when a later run starts, and any test data you inserted persists too. This matters when iterating
|
|
318
|
+
on migrations — see "Iterating on migrations within a session" below.
|
|
319
|
+
|
|
320
|
+
## Inspecting migration state
|
|
321
|
+
|
|
322
|
+
Before acting on migrations (generating, deleting, regenerating, resetting), check the current state. The
|
|
323
|
+
`netlify db status` command is the source of truth for which migrations are applied where.
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
netlify db status
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
The command automatically targets your preview database branch — `NETLIFY_DB_BRANCH` is pre-set for you, so
|
|
330
|
+
no flags are needed.
|
|
331
|
+
|
|
332
|
+
It reports:
|
|
333
|
+
- **Applied**: migrations that have been applied to the branch
|
|
334
|
+
- **Pending**: migration files that exist locally but have not been applied
|
|
335
|
+
- **Missing on disk**: migrations applied on the server but not present locally (drift — stop and investigate)
|
|
336
|
+
- **Out of order**: pending migrations whose prefix sorts before an already-applied migration. The platform
|
|
337
|
+
rejects these, so fix via the "Rule of thumb" below (reset + regenerate). If `drizzle-kit generate` then
|
|
338
|
+
reports no changes, the out-of-order files were redundant and deleting them was the complete fix.
|
|
339
|
+
|
|
340
|
+
Run this before any migration change you're not sure about. If `missing on disk` is non-empty, run
|
|
341
|
+
`netlify db migrations pull --force` to restore the missing files from the branch before generating any new
|
|
342
|
+
migrations. Note that this also overwrites any unapplied migration files you have locally — regenerate those
|
|
343
|
+
with `npx drizzle-kit generate` afterwards if needed.
|
|
344
|
+
|
|
345
|
+
## Iterating on migrations within a session
|
|
346
|
+
|
|
347
|
+
A single agent session can run multiple times, and all runs share one preview database branch. When you realize
|
|
348
|
+
a migration from an earlier run needs to change, the correct action depends on whether the migration has been
|
|
349
|
+
applied to the database yet.
|
|
350
|
+
|
|
351
|
+
### Rule of thumb
|
|
352
|
+
|
|
353
|
+
- If a migration has been **applied** to any database (local dev DB, preview branch, or production), treat it
|
|
354
|
+
as immutable. Roll forward with a new migration that applies the correction. This is always safe.
|
|
355
|
+
- If a migration is **not yet applied** anywhere (it's only on disk), don't edit it in place. Run
|
|
356
|
+
`netlify db migrations reset` to delete it, update `db/schema.ts` to reflect your new intent, then run
|
|
357
|
+
`npx drizzle-kit generate` to produce a fresh migration. Editing SQL or snapshot files directly can
|
|
358
|
+
desync Drizzle Kit's internal state and produce broken migrations on the next generate.
|
|
359
|
+
|
|
360
|
+
### `netlify db migrations reset` — cleaning up unapplied migrations
|
|
361
|
+
|
|
362
|
+
`netlify db migrations reset` deletes local migration files that have **not yet been applied** to your preview
|
|
363
|
+
branch. Applied migrations and their data are left alone.
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
netlify db migrations reset
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
Typical use: after a rebase pulls in new migrations from main, you may have locally-generated migrations that
|
|
370
|
+
now conflict with or duplicate main's work. Running `netlify db migrations reset` clears those unapplied files
|
|
371
|
+
so you can regenerate cleanly.
|
|
372
|
+
|
|
373
|
+
The command is safe — it cannot remove migrations that have been applied, so it cannot produce a broken
|
|
374
|
+
database state.
|
|
375
|
+
|
|
376
|
+
## Connecting to the database
|
|
377
|
+
|
|
378
|
+
Use `netlify db connect` to query the database directly for troubleshooting or inspecting the current schema. Always use
|
|
379
|
+
the `--query` flag for one-shot execution — do NOT use interactive mode.
|
|
380
|
+
|
|
381
|
+
```bash
|
|
382
|
+
# Inspect the current schema
|
|
383
|
+
netlify db connect --query "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"
|
|
384
|
+
|
|
385
|
+
# Check columns on a table
|
|
386
|
+
netlify db connect --query "SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_name = 'users'"
|
|
387
|
+
|
|
388
|
+
# Read data
|
|
389
|
+
netlify db connect --query "SELECT * FROM users LIMIT 10"
|
|
390
|
+
|
|
391
|
+
# Get results as JSON
|
|
392
|
+
netlify db connect --query "SELECT * FROM users LIMIT 10" --json
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
The database connection is read-only. You can use it to inspect the schema and read data, but you cannot insert, update,
|
|
396
|
+
or delete rows.
|
|
397
|
+
|
|
398
|
+
**CRITICAL: NEVER run DDL statements (CREATE, ALTER, DROP, TRUNCATE) or any other schema-mutating queries through
|
|
399
|
+
`netlify db connect`.** The only supported way to change the database schema is through migration files in
|
|
400
|
+
`netlify/database/migrations/`. Running DDL directly will cause the migration state to diverge from the actual schema,
|
|
401
|
+
leading to unpredictable and broken behavior.
|
|
328
402
|
|
|
329
403
|
## Common mistakes to avoid
|
|
330
404
|
|
|
@@ -336,20 +410,13 @@ Drizzle Kit generates migrations in the subdirectory format. Both formats can co
|
|
|
336
410
|
`drizzle-kit@beta`. Installing `drizzle-orm` or `drizzle-kit` without the `@beta` tag pulls the `latest` releases,
|
|
337
411
|
which lack the adapter and will fail. Always install with `drizzle-orm@beta` and `drizzle-kit@beta`.
|
|
338
412
|
|
|
339
|
-
3. **
|
|
340
|
-
a corresponding migration in `netlify/database/migrations/`. With Drizzle ORM, run `npx drizzle-kit generate` after
|
|
341
|
-
updating the schema definition. With the native driver, write a SQL migration file. Schema changes alone do
|
|
342
|
-
nothing — the migration files are what Netlify applies. The application WILL break without them.
|
|
343
|
-
|
|
344
|
-
4. **Editing generated migrations**: Never manually edit migrations created by Drizzle Kit. If you need to change
|
|
345
|
-
something, update the schema and generate a new migration.
|
|
346
|
-
|
|
347
|
-
5. **Missing `.js` extension in imports**: When using TypeScript with ES modules, import paths should include the `.js`
|
|
413
|
+
3. **Missing `.js` extension in imports**: When using TypeScript with ES modules, import paths should include the `.js`
|
|
348
414
|
extension (e.g. `from "./schema.js"`, `from "../../db/index.js"`).
|
|
349
415
|
|
|
350
|
-
|
|
416
|
+
4. **Creating tables with raw SQL when using Drizzle**: If you use Drizzle ORM, define all tables in `db/schema.ts`
|
|
351
417
|
and generate migrations with `drizzle-kit generate`. Do not write raw `CREATE TABLE` SQL — the schema file is the
|
|
352
418
|
source of truth.
|
|
353
419
|
|
|
354
|
-
|
|
355
|
-
|
|
420
|
+
5. **Misunderstanding `netlify db migrations reset`**: This command only deletes migration files that have
|
|
421
|
+
**not yet been applied** to your preview branch. It cannot undo an already-applied migration — to change
|
|
422
|
+
something that's already applied, you must roll forward with a new migration.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/agent-runner-cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.104.0",
|
|
5
5
|
"description": "CLI tool for running Netlify agents",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -83,7 +83,8 @@
|
|
|
83
83
|
"dependencies": {
|
|
84
84
|
"@anthropic-ai/claude-code": "2.1.111",
|
|
85
85
|
"@anthropic-ai/sdk": "0.90.0",
|
|
86
|
-
"@google/gemini-cli": "0.38.
|
|
86
|
+
"@google/gemini-cli": "0.38.2",
|
|
87
|
+
"@netlify/database-proxy": "^0.1.2",
|
|
87
88
|
"@netlify/otel": "^5.1.5",
|
|
88
89
|
"@netlify/ts-cli": "^1.0.4",
|
|
89
90
|
"@openai/codex": "0.121.0",
|