Skip to content

Commit b543889

Browse files
committed
docs: updated README.md and toml reference for profile/databases
1 parent a8ff8e1 commit b543889

2 files changed

Lines changed: 53 additions & 2 deletions

File tree

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ LLM/AI coding assistants are very good in writing code/SQL queries. But they are
1212

1313
Some PostgreSQL MCP server ask you for the database connection. And to perform the administrative tasks you might need SUPERUSER permission. But that's like asking for problem.
1414

15-
1615
We've already seen where this leads: [production databases wiped by AI agents](https://fortune.com/2025/07/23/ai-coding-tool-replit-wiped-database-called-it-a-catastrophic-failure/), and [SQL injection in MCP servers](https://securitylabs.datadoghq.com/articles/mcp-vulnerability-case-study-SQL-injection-in-the-postgresql-mcp-server/) that were supposed to be read-only.
1716

1817
The model doesn't need to *query* your database. It needs to *understand* your schema: the structure, constraints, statistics, and version-specific behavior. That knowledge is structural. It changes when you deploy a migration, not between queries.
@@ -107,7 +106,7 @@ If you can connect to a PostgreSQL instance (local, dev, or production), one com
107106
dryrun init --db "$DATABASE_URL"
108107
```
109108

110-
This creates `dryrun.toml` (with `[project] id` and a default profile), the `.dryrun/` data directory, and introspects the database into `.dryrun/schema.json`. Snapshots are keyed by `(project_id, database_id)`; set `database_id` per profile when a project has multiple databases (e.g. `auth`, `billing`).
109+
This creates `dryrun.toml` (with `[project] id` and default profile), the `.dryrun/` data directory, and introspects the database into `.dryrun/schema.json`. Snapshots are keyed by `(project_id, database_id)`; set `database_id` per profile when a project has multiple databases (e.g. `auth`, `billing`). See [`docs/dryrun-toml.md`](docs/dryrun-toml.md) for the full config reference.
111110

112111
### Option B: Someone else has database access
113112

@@ -134,6 +133,40 @@ dryrun lint
134133

135134
All commands work offline from the schema file. Each project has its own `dryrun.toml` and `.dryrun/`, there is no global state. Add `.dryrun/` to your `.gitignore`.
136135

136+
### Multiple databases per project
137+
138+
`dryrun snapshot take` keys snapshots by `(project_id, database_id)`. The defaults work — `project_id` is your folder name, `database_id` is the actual database name from `current_database()`:
139+
140+
```sh
141+
dryrun init --db "$AUTH_DB" # captures auth
142+
dryrun snapshot take --db "$BILLING_DB" # captures billing into its own stream
143+
dryrun snapshot list --db "$AUTH_DB" # only auth snapshots
144+
```
145+
146+
For stable refs (and so `list` / `diff` can run without retyping URLs), declare profiles in `dryrun.toml`:
147+
148+
```toml
149+
[project]
150+
id = "myapp"
151+
152+
[profiles.auth]
153+
db_url = "${AUTH_DATABASE_URL}"
154+
database_id = "auth"
155+
156+
[profiles.billing]
157+
db_url = "${BILLING_DATABASE_URL}"
158+
database_id = "billing"
159+
```
160+
161+
Then:
162+
163+
```sh
164+
dryrun --profile billing snapshot list
165+
dryrun --profile billing snapshot diff --latest
166+
```
167+
168+
See [`docs/dryrun-toml.md`](docs/dryrun-toml.md) for all profile options.
169+
137170
## MCP server
138171

139172
Add `dryrun` to your AI assistant. If you installed via Homebrew, `dryrun` is already on your PATH:

docs/dryrun-toml.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Project configuration. dryrun finds this file by walking up from the current dir
55
## Minimal example
66

77
```toml
8+
[project]
9+
id = "myapp"
10+
811
[default]
912
profile = "offline"
1013

@@ -14,6 +17,15 @@ schema_file = ".dryrun/schema.json"
1417

1518
That's it. Everything else has sensible defaults.
1619

20+
## Project
21+
22+
```toml
23+
[project]
24+
id = "myapp"
25+
```
26+
27+
Identifies the project. Snapshots are keyed by `(project_id, database_id)` so a single store can hold history for multiple projects without collisions. Defaults to the cwd basename if absent.
28+
1729
## Profiles
1830

1931
A profile points dryrun at a schema source, either an offline JSON snapshot or a live database connection. Most projects have two or three: one for offline work, one for local dev, maybe one for staging. Each profile has a name and exactly one source.
@@ -27,8 +39,14 @@ db_url = "postgresql://dev:dev@localhost:5432/myapp"
2739

2840
[profiles.staging]
2941
db_url = "${STAGING_DATABASE_URL}" # environment variables work
42+
43+
[profiles.prod-auth]
44+
db_url = "${PROD_AUTH_DATABASE_URL}"
45+
database_id = "auth" # set when a project has multiple databases
3046
```
3147

48+
`database_id` defaults to the profile name. Override it when you want the snapshot stream named differently from the profile (e.g. profile `prod-auth` → stream `auth`).
49+
3250
Pick one with `--profile`, or set a default:
3351

3452
```toml

0 commit comments

Comments
 (0)