You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-2Lines changed: 35 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,6 @@ LLM/AI coding assistants are very good in writing code/SQL queries. But they are
12
12
13
13
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.
14
14
15
-
16
15
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.
17
16
18
17
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
107
106
dryrun init --db "$DATABASE_URL"
108
107
```
109
108
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.
111
110
112
111
### Option B: Someone else has database access
113
112
@@ -134,6 +133,40 @@ dryrun lint
134
133
135
134
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`.
136
135
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
+
137
170
## MCP server
138
171
139
172
Add `dryrun` to your AI assistant. If you installed via Homebrew, `dryrun` is already on your PATH:
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
+
17
29
## Profiles
18
30
19
31
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.
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
30
46
```
31
47
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`).
0 commit comments