Create a role for a Postgres branch

postgres roles & traffic

// what it does

Creates a real Postgres role on a branch and prints its credentials — the Postgres equivalent of a branch password. --inherited-roles grants privileges by inheritance: pg_read_all_data for read-only, pg_write_all_data for writes, comma-separated to combine.

// shell

$ pscale role create mydb main analytics-ro --inherited-roles pg_read_all_data
$ pscale role create mydb main app-rw --inherited-roles pg_read_all_data,pg_write_all_data

// gotcha

Credentials print once, at creation — store them straight into your secret manager (for a Cloudflare Worker: into the Hyperdrive config or a Worker secret). Postgres databases don't support `pscale connect`, so this connection string IS how everything connects.

// resources