Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .changeset/hyperdrive-planetscale.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
"wrangler": minor
---

Add experimental `wrangler hyperdrive planetscale` commands for provisioning Cloudflare-billed PlanetScale databases

`wrangler hyperdrive planetscale create <name>` authorizes the Cloudflare billing side and then invokes PlanetScale's own CLI to create the database:

```sh
wrangler hyperdrive planetscale create my-db --org my-org
```

Anything after `--` is forwarded verbatim to `pscale database create`, so PlanetScale's own options are available without Wrangler having to mirror them:

```sh
wrangler hyperdrive planetscale create my-db --org my-org -- \
--region us-east --cluster-size PS-10 --engine postgresql
```

See [PlanetScale's documentation](https://planetscale.com/docs/reference/database#create-a-database) for the supported options.

`pscale` must be installed and logged in. Wrangler authorizes the Cloudflare billing side only, so your PlanetScale credentials stay between you and `pscale`. Set `WRANGLER_PSCALE_BIN` to point Wrangler at a specific binary.

`wrangler hyperdrive planetscale signature` prints that authorization as JSON instead, for callers that would rather drive `pscale` themselves:

```sh
wrangler hyperdrive planetscale signature |
pscale database create <name> --org <org> --cloudflare-billing @-
```

Piping keeps the signature out of the process list, where any local user could otherwise read it and use it to create a database billed to your account.

Both commands are experimental and their interfaces may change.
5 changes: 5 additions & 0 deletions packages/workers-utils/src/environment-variables/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ type VariableNames =
/** Docker host configuration (handled separately from environment variable factory). */
| "DOCKER_HOST"

// ## PlanetScale Configuration

/** Path to the PlanetScale CLI binary (default: "pscale"). */
| "WRANGLER_PSCALE_BIN"

/** Environment variable used to signal that the current process is being run by the open-next deploy command. */
| "OPEN_NEXT_DEPLOY";

Expand Down
Loading
Loading