@netlify/agent-runner-cli 1.150.0 → 1.151.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 +184 -172
- package/dist/bin.js +276 -264
- package/dist/index.js +199 -187
- package/dist/skills/netlify-database/SKILL.ask.md +54 -0
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: netlify-database
|
|
3
|
+
description: Read the project's Netlify Database (managed Postgres) to answer questions about its schema or its data. Read-only - this run cannot create, migrate, or modify a database. Use when a question is about what data the project stores, what the schema looks like, or what is currently in a table.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Netlify Database (read-only)
|
|
7
|
+
|
|
8
|
+
Netlify Database is a fully managed Postgres database built into the Netlify platform. This run is read-only: you can
|
|
9
|
+
inspect the schema and read data to answer the question, and nothing else.
|
|
10
|
+
|
|
11
|
+
If the run has database access, the branch you are connected to is named in the "Netlify Database (read-only)" section
|
|
12
|
+
of your context. If that section is absent, this project has no database available to this run - say so rather than
|
|
13
|
+
guessing at a schema.
|
|
14
|
+
|
|
15
|
+
## Querying
|
|
16
|
+
|
|
17
|
+
Use `netlify db connect` with `--query` for one-shot execution. Never run it without `--query`: that opens an
|
|
18
|
+
interactive session which never returns and will hang the run.
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# List tables
|
|
22
|
+
netlify db connect --query "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"
|
|
23
|
+
|
|
24
|
+
# Describe a table
|
|
25
|
+
netlify db connect --query "SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_name = 'users'"
|
|
26
|
+
|
|
27
|
+
# Count rows
|
|
28
|
+
netlify db connect --query "SELECT count(*) FROM users"
|
|
29
|
+
|
|
30
|
+
# Read a few rows as JSON
|
|
31
|
+
netlify db connect --query "SELECT id, created_at FROM users ORDER BY created_at DESC LIMIT 5" --json
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Prefer `information_schema` queries and aggregates. When you do read rows, use a `LIMIT` and select only the columns
|
|
35
|
+
you need - leave out columns holding personal data, credentials, or tokens. Query output is shown to the user and
|
|
36
|
+
stored with the session.
|
|
37
|
+
|
|
38
|
+
## What this run cannot do
|
|
39
|
+
|
|
40
|
+
- No writes. The connection uses a read-only role, so `INSERT`, `UPDATE`, `DELETE`, and DDL are refused by Postgres.
|
|
41
|
+
- No migrations. Do not run `drizzle-kit`, `netlify db migrations reset`, or `netlify db migrate`, and do not write
|
|
42
|
+
migration files. If answering the question means describing a schema change, describe it - the change itself belongs
|
|
43
|
+
to a later run that is allowed to edit the project.
|
|
44
|
+
- No provisioning. If the project has no database, this run cannot create one.
|
|
45
|
+
|
|
46
|
+
## Reading schema from the codebase
|
|
47
|
+
|
|
48
|
+
The schema definition in the repository is often the better answer for "what does the schema look like" questions, and
|
|
49
|
+
it is cheaper to read than the database. Look for `db/schema.ts` (Drizzle) or SQL files in
|
|
50
|
+
`netlify/database/migrations/`. Query the database when the question is about the data itself, or when you need to
|
|
51
|
+
confirm what is actually applied to the branch rather than what the code intends.
|
|
52
|
+
|
|
53
|
+
Migration files on disk are not necessarily applied to the branch you are reading, so treat the repository as intent
|
|
54
|
+
and the database as the current state.
|