Make sure to first set up your PlanetScale developer environment. Once you’ve installed the pscale CLI, you can interact with PlanetScale and manage your databases straight from the command line.
Create a new role for a Postgres database branch:Usage:
Report incorrect code
Copy
Ask AI
pscale role create <database> <branch> <name> [flags]
Available flags:
--inherited-roles string - Comma-separated list of role names to inherit privileges from. Common values are ‘pg_read_all_data’ for read access, ‘pg_write_all_data’ for write access, and ‘postgres’ for admin access.
--ttl duration - TTL defines the time to live for the role. Durations such as “30m”, “24h”, or bare integers such as “3600” (seconds) are accepted. The default TTL is 0s, which means the role will never expire.
Example:
Report incorrect code
Copy
Ask AI
pscale role create my-database main api-user --inherited-roles pg_read_all_data --ttl 24h
Reassign objects owned by one role to any other role:
Be careful with this command. Reassigning objects like databases, tables, or schemas will change who is able to write to them, alter them, or delete them.
Usage:
Report incorrect code
Copy
Ask AI
pscale role reassign <database> <branch> <role-id> --successor <role-id>
Available flags:
--force - Force reset without confirmation
Example:
Report incorrect code
Copy
Ask AI
pscale role reassign my-database main role-123 --successor postgres
Be careful with this command. If you are currently using the affected role’s credentials for connecting to your database, running this command will reset the password, and new connections using the old password will not work.
Usage:
Report incorrect code
Copy
Ask AI
pscale role reset <database> <branch> <role-id> [flags]
Reset the credentials for the default postgres role:
Be careful with this command. If you are currently using the default postgres role credentials for connecting to your database, running this command will reset the password, and new connections using the old password will not work.
Usage:
Report incorrect code
Copy
Ask AI
pscale role reset-default <database> <branch> [flags]