@the-meridian/cli 1.0.2 → 1.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @the-meridian/cli
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ef6a53f: Add `meridian db credential list` and `meridian db credential revoke <credential>` for the credentials a backend running outside Meridian uses to reach a hosted environment's MySQL database through the Meridian database gateway. `list` shows each credential's label, MySQL user, access mode, status, last connection and certificate expiry; `revoke` drops a credential after asking (or with `--yes`), so a leaked one can be cut off from a terminal. Both take `--env <name>`. Creating and rotating credentials stay in the dashboard.
8
+
9
+ ### Patch Changes
10
+
11
+ - be18bb6: The per-developer MySQL database is now called a **developer database** in every message and command description, matching the **Developer databases** page in the dashboard. Nothing about how it works changes.
12
+
13
+ ## 1.0.3
14
+
15
+ ### Patch Changes
16
+
17
+ - faaf2bf: Clarify punctuation in the README.
18
+
3
19
  ## 1.0.2
4
20
 
5
21
  ### Patch Changes
package/README.md CHANGED
@@ -17,7 +17,7 @@ meridian dev # every day
17
17
  - Node.js 20 or newer
18
18
  - A Meridian account with access to at least one organization and app
19
19
 
20
- You do **not** need Docker, a local MySQL server, `gcloud`, or the Cloud SQL Auth Proxy — the CLI downloads and manages the proxy for you.
20
+ You do **not** need Docker, a local MySQL server, `gcloud`, or the Cloud SQL Auth Proxy. The CLI downloads and manages the proxy for you.
21
21
 
22
22
  ## How it works
23
23
 
@@ -98,6 +98,17 @@ Runs `npx prisma db seed` with the proxy up and `DATABASE_URL` set. Extra args:
98
98
 
99
99
  Opens a SQL shell against the dev database: the real `mysql` client when it's on `PATH` (the password is passed via `MYSQL_PWD`, so it never appears in `ps`), otherwise a small built-in REPL over `mysql2`. `--repl` forces the built-in one, and `-e "SELECT 1"` runs a single statement and exits (`--json` formats the rows as JSON).
100
100
 
101
+ ### `meridian db credential`
102
+
103
+ Lists and revokes credentials for reaching a hosted environment's MySQL database from a backend running outside Meridian, through the Meridian database gateway (mutual TLS plus a password). This acts on a hosted environment's database, not the developer database.
104
+
105
+ ```bash
106
+ meridian db credential list --env production
107
+ meridian db credential revoke aws-backend --env production --yes
108
+ ```
109
+
110
+ Creating and rotating credentials happen in the dashboard (Hosting > Database > External access), behind a browser session: a CLI token cannot issue database access. Revoking needs the Credentials: Manage permission on the app.
111
+
101
112
  ### Global flags
102
113
 
103
114
  Accepted before or after the command name, so both `meridian --json whoami` and `meridian whoami --json` work.
@@ -144,7 +155,7 @@ SHADOW_DATABASE_URL="mysql://devu_88_15:<password>@127.0.0.1:3307/devdb_88_u15_s
144
155
  ```
145
156
 
146
157
  - `SHADOW_DATABASE_URL` points at a second database provisioned for you, which `prisma migrate dev` needs (see below). It is reachable with the same credentials and is dropped when your dev database is.
147
- - Every other line — comments, ordering, blank lines, quoting style — is preserved; only these two are replaced.
158
+ - Every other line (comments, ordering, blank lines, quoting style) is preserved; only these two are replaced.
148
159
  - The first time a file is modified, a one-time copy is saved as `.env.backup`, with the same permissions as the file it copies.
149
160
  - An existing file keeps its permissions; a file the CLI creates is `0600`, because the line it writes contains a live password.
150
161
  - The port changes between runs when the preferred port is busy, so re-running `meridian dev` rewrites the line.
@@ -167,13 +178,13 @@ datasource db {
167
178
 
168
179
  `meridian migrate` offers to add the `shadowDatabaseUrl` line for you the first time it finds it missing, and writes it in place. It asks rather than just doing it, because a schema is source you keep in git, unlike the generated `.env`. A datasource that already names some other variable is left alone.
169
180
 
170
- `shadowDatabaseUrl` is required because `prisma migrate dev` does not apply migrations directly: it replays your migration history into a throwaway shadow database and diffs that against your schema to detect drift. Prisma creates that database itself when it can, and your dev user cannot — it holds privileges on its own two databases and nothing else, so `CREATE DATABASE` is denied and Prisma reports `P3014`. Meridian provisions the shadow database per developer instead of granting the privilege, because Prisma names shadow databases with a fixed `prisma_migrate_shadow_db_*` prefix: a grant broad enough to cover that would be shared by every developer on the instance.
181
+ `shadowDatabaseUrl` is required because `prisma migrate dev` does not apply migrations directly: it replays your migration history into a throwaway shadow database and diffs that against your schema to detect drift. Prisma creates that database itself when it can, and your dev user cannot: it holds privileges on its own two databases and nothing else, so `CREATE DATABASE` is denied and Prisma reports `P3014`. Meridian provisions the shadow database per developer instead of granting the privilege, because Prisma names shadow databases with a fixed `prisma_migrate_shadow_db_*` prefix: a grant broad enough to cover that would be shared by every developer on the instance.
171
182
 
172
183
  Only `meridian migrate` needs it. `dev`, `db seed` and `db shell` run fine without it.
173
184
 
174
185
  ## Non-interactive and CI use
175
186
 
176
- Prompts are skipped automatically when stdin/stderr aren't TTYs, when `CI` is set, or when `MERIDIAN_NON_INTERACTIVE` is set — in that mode a command that would have prompted fails with a message naming the flag or variable to set instead.
187
+ Prompts are skipped automatically when stdin/stderr aren't TTYs, when `CI` is set, or when `MERIDIAN_NON_INTERACTIVE` is set. In that mode a command that would have prompted fails with a message naming the flag or variable to set instead.
177
188
 
178
189
  | Variable | Purpose |
179
190
  | --- | --- |
@@ -184,7 +195,7 @@ Prompts are skipped automatically when stdin/stderr aren't TTYs, when `CI` is se
184
195
  | `MERIDIAN_NON_INTERACTIVE` | Same as `--no-input` |
185
196
  | `MERIDIAN_NO_BROWSER` | Same as `login --no-browser` |
186
197
  | `MERIDIAN_DEV_ACTIVE` | Set to `1` in every process `meridian dev` starts. Read it to detect that your script is already inside a session; setting it yourself makes `meridian dev` refuse to start |
187
- | `MERIDIAN_DEV_DATABASE_ID` | Exported (alongside `DATABASE_URL`) into the children of `meridian dev`, `migrate` and `db …`, holding the id of the dev database that session provisioned. The Meridian SDK sends it as `devDatabaseId` on its identify call, so installs a locally-run app creates are billed to your dev database. Set by the CLI only — never set it yourself |
198
+ | `MERIDIAN_DEV_DATABASE_ID` | Exported (alongside `DATABASE_URL`) into the children of `meridian dev`, `migrate` and `db …`, holding the id of the dev database that session provisioned. The Meridian SDK sends it as `devDatabaseId` on its identify call, so installs a locally-run app creates are billed to your dev database. Set by the CLI only. Never set it yourself |
188
199
  | `MERIDIAN_PROXY_PATH` | Use an existing proxy binary instead of downloading one |
189
200
  | `MERIDIAN_PROXY_VERSION` | Pin a different proxy version (checksum is fetched from that release) |
190
201
  | `MERIDIAN_PROXY_SKIP_CHECKSUM=1` | Allow install when no checksum is published. Use only if you trust the source |
@@ -198,39 +209,39 @@ Read commands support `--json`. Errors are also JSON in that mode:
198
209
 
199
210
  ## Troubleshooting
200
211
 
201
- **`You are not logged in to Meridian.`** — Run `meridian login`.
212
+ **`You are not logged in to Meridian.`**: Run `meridian login`.
202
213
 
203
- **`This project is not linked to a Meridian app.`** — Run `meridian link` in the project root. The CLI looks for `.meridian/project.json` in the current directory and its parents.
214
+ **`This project is not linked to a Meridian app.`**: Run `meridian link` in the project root. The CLI looks for `.meridian/project.json` in the current directory and its parents.
204
215
 
205
- **`Your Meridian CLI token is no longer valid (401).`** — The token was revoked or expired. Run `meridian login` again.
216
+ **`Your Meridian CLI token is no longer valid (401).`**: The token was revoked or expired. Run `meridian login` again.
206
217
 
207
- **`Provisioning the development database failed.`** — Provisioning ended in an error state on Meridian's side; the reason the API reports is appended to the message. Check the dashboard for the full history, then re-run `meridian dev` to retry.
218
+ **`Provisioning the development database failed.`**: Provisioning ended in an error state on Meridian's side; the reason the API reports is appended to the message. Check the dashboard for the full history, then re-run `meridian dev` to retry.
208
219
 
209
- **`The development database is not ready yet.`** — A credentials or reset call arrived before provisioning finished (HTTP 409). `meridian dev` polls for you, so this normally only appears when a command runs against a database that is still being created.
220
+ **`The development database is not ready yet.`**: A credentials or reset call arrived before provisioning finished (HTTP 409). `meridian dev` polls for you, so this normally only appears when a command runs against a database that is still being created.
210
221
 
211
- **`Could not reach 127.0.0.1:<port>/<db> (ECONNREFUSED).`** — Nothing is listening. `meridian dev` and `meridian migrate` start the proxy themselves; if you're running Prisma directly, keep `meridian dev` running in another terminal.
222
+ **`Could not reach 127.0.0.1:<port>/<db> (ECONNREFUSED).`**: Nothing is listening. `meridian dev` and `meridian migrate` start the proxy themselves; if you're running Prisma directly, keep `meridian dev` running in another terminal.
212
223
 
213
- **`Timed out waiting for MySQL …`** — The proxy is up but can't reach Cloud SQL. Check whether a VPN, firewall, or corporate proxy blocks outbound connections, then retry with `--verbose` to see the proxy's own logs.
224
+ **`Timed out waiting for MySQL …`**: The proxy is up but can't reach Cloud SQL. Check whether a VPN, firewall, or corporate proxy blocks outbound connections, then retry with `--verbose` to see the proxy's own logs.
214
225
 
215
- **`Another process is already listening on that port.`** — Pass `--port` to choose a different one.
226
+ **`Another process is already listening on that port.`**: Pass `--port` to choose a different one.
216
227
 
217
- **Proxy download fails** (air-gapped network, blocked storage.googleapis.com) — Install the [Cloud SQL Auth Proxy](https://github.com/GoogleCloudPlatform/cloud-sql-proxy) yourself and set `MERIDIAN_PROXY_PATH` to it.
228
+ **Proxy download fails** (air-gapped network, blocked storage.googleapis.com): Install the [Cloud SQL Auth Proxy](https://github.com/GoogleCloudPlatform/cloud-sql-proxy) yourself and set `MERIDIAN_PROXY_PATH` to it.
218
229
 
219
- **Checksum verification failed** — A cached binary that no longer matches its published SHA-256 is deleted and downloaded again automatically. If a fresh download also fails verification the CLI refuses to install it, which usually means something on the network is rewriting the response. Don't reach for `MERIDIAN_PROXY_SKIP_CHECKSUM` in that situation.
230
+ **Checksum verification failed**: A cached binary that no longer matches its published SHA-256 is deleted and downloaded again automatically. If a fresh download also fails verification the CLI refuses to install it, which usually means something on the network is rewriting the response. Don't reach for `MERIDIAN_PROXY_SKIP_CHECKSUM` in that situation.
220
231
 
221
- **A migration failed and left the schema half-applied** — `meridian migrate` restores the pre-migration snapshot automatically. To redo it by hand, use the newest file in `.meridian/snapshots/`, or run `meridian db reset` for a clean slate.
232
+ **A migration failed and left the schema half-applied**: `meridian migrate` restores the pre-migration snapshot automatically. To redo it by hand, use the newest file in `.meridian/snapshots/`, or run `meridian db reset` for a clean slate.
222
233
 
223
- **The rollback itself failed** — Treat the database as unsafe: the reset succeeded but the replay didn't finish, so the schema is partial. Start the proxy with `meridian dev` in another terminal and replay the snapshot by hand (`mysql … < .meridian/snapshots/<timestamp>.sql`, or `meridian db shell` and paste it), or take the clean slate with `meridian db reset --migrate`. The failing statement's index is in the error message.
234
+ **The rollback itself failed**: Treat the database as unsafe: the reset succeeded but the replay didn't finish, so the schema is partial. Start the proxy with `meridian dev` in another terminal and replay the snapshot by hand (`mysql … < .meridian/snapshots/<timestamp>.sql`, or `meridian db shell` and paste it), or take the clean slate with `meridian db reset --migrate`. The failing statement's index is in the error message.
224
235
 
225
- **`meridian dev` says it would call itself** — Your `npm run dev` script invokes `meridian dev`. Point `dev_command` in `.meridian/project.json` at the real dev server (for example `next dev`), or run `meridian dev -- next dev`.
236
+ **`meridian dev` says it would call itself**: Your `npm run dev` script invokes `meridian dev`. Point `dev_command` in `.meridian/project.json` at the real dev server (for example `next dev`), or run `meridian dev -- next dev`.
226
237
 
227
- **"…would not touch the managed development database"** — Your Prisma datasource does not read `DATABASE_URL`, so Prisma would ignore the database the CLI just connected you to and use whatever the schema hardcodes (typically `file:dev.sqlite`). Set `provider = "mysql"` and `url = env("DATABASE_URL")`, and regenerate any migrations created for the old database — their SQL is dialect-specific and MySQL will reject it. Projects that deliberately manage their datasource some other way can set `"skip_datasource_check": true` in `.meridian/project.json`.
238
+ **"…would not touch the managed development database"**: Your Prisma datasource does not read `DATABASE_URL`, so Prisma would ignore the database the CLI just connected you to and use whatever the schema hardcodes (typically `file:dev.sqlite`). Set `provider = "mysql"` and `url = env("DATABASE_URL")`, and regenerate any migrations created for the old database, because their SQL is dialect-specific and MySQL will reject it. Projects that deliberately manage their datasource some other way can set `"skip_datasource_check": true` in `.meridian/project.json`.
228
239
 
229
- **"written for a different database engine"** — `migrate` screens `prisma/migrations` before it provisions anything, because a history generated for another engine cannot apply to MySQL. SQLite and Postgres quote identifiers as `"Session"`, which MySQL reads as a string literal, and SQLite's `TEXT` primary keys are invalid as MySQL keys. Migration SQL is dialect-specific, so the history has to be regenerated: if it has only ever run locally, delete `prisma/migrations` and re-run. This is the normal state of a Shopify app template, which ships SQLite migrations. `--allow-foreign-migrations` waives the check.
240
+ **"written for a different database engine"**: `migrate` screens `prisma/migrations` before it provisions anything, because a history generated for another engine cannot apply to MySQL. SQLite and Postgres quote identifiers as `"Session"`, which MySQL reads as a string literal, and SQLite's `TEXT` primary keys are invalid as MySQL keys. Migration SQL is dialect-specific, so the history has to be regenerated: if it has only ever run locally, delete `prisma/migrations` and re-run. This is the normal state of a Shopify app template, which ships SQLite migrations. `--allow-foreign-migrations` waives the check.
230
241
 
231
242
  If an earlier attempt already failed against the database, run `meridian db reset` before retrying. Prisma records the failure in `_prisma_migrations`, and once the history is deleted that row names a migration that no longer exists on disk, which Prisma reports as drift and refuses to work past.
232
243
 
233
- **"declares no `shadowDatabaseUrl`"**, or Prisma's **`P3014`** — `prisma migrate dev` needs a shadow database and your dev user cannot create one. Meridian provisions it and exports `SHADOW_DATABASE_URL`; add `shadowDatabaseUrl = env("SHADOW_DATABASE_URL")` to your datasource. If you hit `P3014` despite having that line, your dev database predates shadow databases — `meridian db reset` re-provisions it.
244
+ **"declares no `shadowDatabaseUrl`"**, or Prisma's **`P3014`**: `prisma migrate dev` needs a shadow database and your dev user cannot create one. Meridian provisions it and exports `SHADOW_DATABASE_URL`; add `shadowDatabaseUrl = env("SHADOW_DATABASE_URL")` to your datasource. If you hit `P3014` despite having that line, your dev database predates shadow databases. `meridian db reset` re-provisions it.
234
245
 
235
246
  ## Development
236
247