PlanetScale

PlanetScale is a managed database platform for MySQL (built on Vitess) and PostgreSQL. It uses Git-style branches for schema changes and deploy requests to review and ship those changes safely.

With the PlanetScale block, you can:

  • Inspect databases and branches: List the databases in an organization, read database details, and list or read branches
  • Manage branches: Create development branches from a parent, restore a backup into a new branch, or delete branches you no longer need
  • Work with backups: Create on-demand backups, list backups for a branch, and check a backup's state, size, and expiration
  • Ship schema changes (Vitess): Create deploy requests, review or approve them, queue them for deployment, and close them

To connect, create a service token in your PlanetScale organization settings and grant it access to the databases and actions your workflow needs. Enter the service token ID, the service token, and your organization slug in the block.

In Sim, the PlanetScale block lets your agents manage database operations as part of a workflow: spin up a branch when a pull request opens, take a backup before a release, report on backup health every day, or open and track a deploy request for a schema change. To run SQL queries against a database, use the MySQL or PostgreSQL block.

Usage Instructions

Manage PlanetScale databases and branches, create and inspect backups, and create, review, queue, and close Vitess deploy requests. Authenticate with an organization service token. Deploy-request actions require a Vitess database; SQL queries are available through the MySQL and PostgreSQL integrations.

Actions

PlanetScale List Databases

List databases

Input

ParameterTypeRequiredDescription
serviceTokenIdstringYesPlanetScale service token ID
serviceTokenstringYesPlanetScale service token secret
organizationstringYesPlanetScale organization slug
qstringNoSearch term to filter databases by name
pagenumberNoIf provided, specifies the page offset of returned results
perPagenumberNoIf provided, specifies the number of returned results

Output

ParameterTypeDescription
paginationjsonPagination metadata
↳ currentPagenumbercurrent page
↳ perPagenumberper page
↳ nextPagenumbernext page
↳ totalCountnumbertotal count
↳ totalPagesnumbertotal pages
databasesarraydatabases
↳ idstringThe ID of the database
↳ namestringName of the database
↳ kindstringThe kind of database
↳ statestringState of the database
↳ readybooleanIf the database is ready to be used
↳ defaultBranchstringThe default branch for the database
↳ branchesCountnumberThe total number of database branches
↳ deletionProtectedbooleanWhether deletion protection is enabled for the database
↳ requireApprovalForDeploybooleanWhether an approval is required to deploy schema changes to this database
↳ createdAtstringWhen the database was created
↳ updatedAtstringWhen the database was last updated
↳ htmlUrlstringThe URL to see this database's branches in the web UI

PlanetScale Get Database

Get a database

Input

ParameterTypeRequiredDescription
serviceTokenIdstringYesPlanetScale service token ID
serviceTokenstringYesPlanetScale service token secret
organizationstringYesPlanetScale organization slug
databasestringYesDatabase name slug from list_databases. Example: app-db.

Output

ParameterTypeDescription
databasejsonDatabase details
↳ idstringThe ID of the database
↳ namestringName of the database
↳ kindstringThe kind of database
↳ statestringState of the database
↳ readybooleanIf the database is ready to be used
↳ defaultBranchstringThe default branch for the database
↳ branchesCountnumberThe total number of database branches
↳ deletionProtectedbooleanWhether deletion protection is enabled for the database
↳ requireApprovalForDeploybooleanWhether an approval is required to deploy schema changes to this database
↳ createdAtstringWhen the database was created
↳ updatedAtstringWhen the database was last updated
↳ htmlUrlstringThe URL to see this database's branches in the web UI

PlanetScale List Branches

List branches

Input

ParameterTypeRequiredDescription
serviceTokenIdstringYesPlanetScale service token ID
serviceTokenstringYesPlanetScale service token secret
organizationstringYesPlanetScale organization slug
databasestringYesDatabase name slug from list_databases. Example: app-db.
qstringNoSearch branches by name
productionbooleanNoFilter branches by production status
safeMigrationsbooleanNoFilter branches by safe migrations (DDL protection)
orderstringNoOrder branches by created_at time
pagenumberNoIf provided, specifies the page offset of returned results
perPagenumberNoIf provided, specifies the number of returned results

Output

ParameterTypeDescription
paginationjsonPagination metadata
↳ currentPagenumbercurrent page
↳ perPagenumberper page
↳ nextPagenumbernext page
↳ totalCountnumbertotal count
↳ totalPagesnumbertotal pages
branchesarraybranches
↳ idstringThe ID of the branch
↳ namestringThe name of the branch
↳ kindstringThe kind of branch
↳ statestringThe current state of the branch
↳ readybooleanWhether or not the branch is ready to serve queries
↳ productionbooleanWhether or not the branch is a production branch
↳ safeMigrationsbooleanWhether or not the branch has safe migrations enabled
↳ deletionProtectedbooleanWhether deletion protection is enabled for the branch
↳ parentBranchstringThe name of the parent branch from which the branch was created
↳ createdAtstringWhen the branch was created
↳ updatedAtstringWhen the branch was last updated
↳ htmlUrlstringPlanetscale app URL for the branch

PlanetScale Get Branch

Get a branch

Input

ParameterTypeRequiredDescription
serviceTokenIdstringYesPlanetScale service token ID
serviceTokenstringYesPlanetScale service token secret
organizationstringYesPlanetScale organization slug
databasestringYesDatabase name slug from list_databases. Example: app-db.
branchstringYesBranch name from list_branches. Example: main.

Output

ParameterTypeDescription
branchjsonBranch details
↳ idstringThe ID of the branch
↳ namestringThe name of the branch
↳ kindstringThe kind of branch
↳ statestringThe current state of the branch
↳ readybooleanWhether or not the branch is ready to serve queries
↳ productionbooleanWhether or not the branch is a production branch
↳ safeMigrationsbooleanWhether or not the branch has safe migrations enabled
↳ deletionProtectedbooleanWhether deletion protection is enabled for the branch
↳ parentBranchstringThe name of the parent branch from which the branch was created
↳ createdAtstringWhen the branch was created
↳ updatedAtstringWhen the branch was last updated
↳ htmlUrlstringPlanetscale app URL for the branch

PlanetScale Create Branch

Create a branch

Input

ParameterTypeRequiredDescription
serviceTokenIdstringYesPlanetScale service token ID
serviceTokenstringYesPlanetScale service token secret
organizationstringYesPlanetScale organization slug
databasestringYesThe name of the database the branch belongs to
namestringYesThe name of the branch to create
deletionProtectedbooleanNoWhether deletion protection is enabled for the branch
parentBranchstringNoThe name of the parent branch. Defaults to the database's default branch if not provided.
backupIdstringNoIf provided, restores the backup's schema and data to the new branch. Must have restore_production_branch_backup\(s\) or restore_backup\(s\) access to do this.
regionstringNoThe region to create the branch in. If not provided, the branch will be created in the default region for its database.
restorePointstringNoRestore from a point-in-time recovery timestamp (e.g. 2023-01-01T00:00:00Z). Available only for PostgreSQL databases.
replicasnumberNoFor PostgreSQL backup restores and point-in-time recovery, the number of additional replicas from 0 to 8, subject to the target cluster size. 0 creates a single-node branch. If omitted, the target cluster size's minimum is used.
seedDatastringNoIf provided, restores the last successful backup's schema and data to the new branch. Must have restore_production_branch_backup\(s\) or restore_backup\(s\) access to do this, in addition to Data Branching™ being enabled for the branch.
clusterSizestringNoThe database cluster size. Required when backupId is provided, optional otherwise. Options: PS_10, PS_20, PS_40, ..., PS_2800
majorVersionstringNoFor PostgreSQL and Neki databases, the PostgreSQL major version to use for the branch. Defaults to the major version of the parent branch if it exists or the database's default branch major version. Ignored for branches restored from backups.

Output

ParameterTypeDescription
branchjsonBranch details
↳ idstringThe ID of the branch
↳ namestringThe name of the branch
↳ kindstringThe kind of branch
↳ statestringThe current state of the branch
↳ readybooleanWhether or not the branch is ready to serve queries
↳ productionbooleanWhether or not the branch is a production branch
↳ safeMigrationsbooleanWhether or not the branch has safe migrations enabled
↳ deletionProtectedbooleanWhether deletion protection is enabled for the branch
↳ parentBranchstringThe name of the parent branch from which the branch was created
↳ createdAtstringWhen the branch was created
↳ updatedAtstringWhen the branch was last updated
↳ htmlUrlstringPlanetscale app URL for the branch

PlanetScale Delete Branch

Delete a branch

Input

ParameterTypeRequiredDescription
serviceTokenIdstringYesPlanetScale service token ID
serviceTokenstringYesPlanetScale service token secret
organizationstringYesPlanetScale organization slug
databasestringYesThe name of the database the branch belongs to
branchstringYesThe name of the branch
deleteDescendantsbooleanNoIf true, recursively delete all descendant branches along with this branch

Output

ParameterTypeDescription
deletedbooleanWhether the branch was deleted

PlanetScale List Backups

List backups

Input

ParameterTypeRequiredDescription
serviceTokenIdstringYesPlanetScale service token ID
serviceTokenstringYesPlanetScale service token secret
organizationstringYesPlanetScale organization slug
databasestringYesThe name of the database the branch belongs to
branchstringYesThe name of the branch
allbooleanNoWhether to include all backups, including deleted ones
statestringNoFilter backups by state
policystringNoFilter backups by backup policy ID
fromstringNoFilter backups started after this date (e.g. 2023-01-01T00:00:00Z)
tostringNoFilter backups started before this date (e.g. 2023-01-31T23:59:59Z)
runningAtstringNoFilter backups that are running during a specific time (e.g. 2023-01-01T00:00:00Z..2023-01-01T23:59:59Z)
productionbooleanNoFilter backups by production branch
pagenumberNoIf provided, specifies the page offset of returned results
perPagenumberNoIf provided, specifies the number of returned results

Output

ParameterTypeDescription
paginationjsonPagination metadata
↳ currentPagenumbercurrent page
↳ perPagenumberper page
↳ nextPagenumbernext page
↳ totalCountnumbertotal count
↳ totalPagesnumbertotal pages
backupsarraybackups
↳ idstringThe ID of the backup
↳ namestringThe name of the backup
↳ statestringThe current state of the backup
↳ sizenumberThe size of the backup in bytes
↳ estimatedStorageCostnumberThe estimated storage cost of the backup
↳ protectedbooleanWhether or not the backup is protected from deletion
↳ createdAtstringWhen the backup was created
↳ updatedAtstringWhen the backup was last updated
↳ startedAtstringWhen the backup started
↳ completedAtstringWhen the backup completed
↳ expiresAtstringWhen the backup expires

PlanetScale Get Backup

Get a backup

Input

ParameterTypeRequiredDescription
serviceTokenIdstringYesPlanetScale service token ID
serviceTokenstringYesPlanetScale service token secret
organizationstringYesPlanetScale organization slug
backupIdstringYesThe ID for the backup
databasestringYesThe name of the database the branch belongs to
branchstringYesThe name of the branch

Output

ParameterTypeDescription
backupjsonBackup details
↳ idstringThe ID of the backup
↳ namestringThe name of the backup
↳ statestringThe current state of the backup
↳ sizenumberThe size of the backup in bytes
↳ estimatedStorageCostnumberThe estimated storage cost of the backup
↳ protectedbooleanWhether or not the backup is protected from deletion
↳ createdAtstringWhen the backup was created
↳ updatedAtstringWhen the backup was last updated
↳ startedAtstringWhen the backup started
↳ completedAtstringWhen the backup completed
↳ expiresAtstringWhen the backup expires

PlanetScale Create Backup

Create a backup

Input

ParameterTypeRequiredDescription
serviceTokenIdstringYesPlanetScale service token ID
serviceTokenstringYesPlanetScale service token secret
organizationstringYesPlanetScale organization slug
databasestringYesThe name of the database the branch belongs to
branchstringYesThe name of the branch
namestringNoName for the backup
retentionUnitstringNoUnit for the retention period of the backup
retentionValuenumberNoValue between 1 and 1000 for the retention period of the backup (i.e retention_value 6 and retention_unit hour means 6 hours)
emergencybooleanNoWhether the backup is an immediate backup that may affect database performance. Emergency backups are only supported for PostgreSQL databases.

Output

ParameterTypeDescription
backupjsonBackup details
↳ idstringThe ID of the backup
↳ namestringThe name of the backup
↳ statestringThe current state of the backup
↳ sizenumberThe size of the backup in bytes
↳ estimatedStorageCostnumberThe estimated storage cost of the backup
↳ protectedbooleanWhether or not the backup is protected from deletion
↳ createdAtstringWhen the backup was created
↳ updatedAtstringWhen the backup was last updated
↳ startedAtstringWhen the backup started
↳ completedAtstringWhen the backup completed
↳ expiresAtstringWhen the backup expires

PlanetScale List Deploy Requests

List deploy requests (Vitess only)

Input

ParameterTypeRequiredDescription
serviceTokenIdstringYesPlanetScale service token ID
serviceTokenstringYesPlanetScale service token secret
organizationstringYesPlanetScale organization slug
databasestringYesThe name of the deploy request's database
statestringNoFilter by state of the deploy request (open, closed, deployed)
branchstringNoFilter by the name of the branch the deploy request is created from
intoBranchstringNoFilter by the name of the branch the deploy request will be merged into
deployedAtstringNoFilter deploy requests by the date they were deployed. (e.g. 2023-01-01T00:00:00Z..2023-01-31T23:59:59Z)
runningAtstringNoFilter deploy requests by the date they were running. (e.g. 2023-01-01T00:00:00Z..2023-01-31T23:59:59Z)
pagenumberNoIf provided, specifies the page offset of returned results
perPagenumberNoIf provided, specifies the number of returned results

Output

ParameterTypeDescription
paginationjsonPagination metadata
↳ currentPagenumbercurrent page
↳ perPagenumberper page
↳ nextPagenumbernext page
↳ totalCountnumbertotal count
↳ totalPagesnumbertotal pages
deployRequestsarraydeploy requests
↳ idstringThe ID of the deploy request
↳ numbernumberThe number of the deploy request
↳ branchstringThe name of the branch the deploy request was created from
↳ intoBranchstringThe name of the branch the deploy request will be merged into
↳ statestringWhether the deploy request is open or closed
↳ deploymentStatestringThe deployment state of the deploy request
↳ approvedbooleanWhether or not the deploy request is approved
↳ numCommentsnumberThe number of comments on the deploy request
↳ notesstringNotes on the deploy request
↳ createdAtstringWhen the deploy request was created
↳ updatedAtstringWhen the deploy request was last updated
↳ closedAtstringWhen the deploy request was closed
↳ deployedAtstringWhen the deploy request was deployed
↳ htmlUrlstringThe PlanetScale app address for the deploy request

PlanetScale Get Deploy Request

Get a deploy request (Vitess only)

Input

ParameterTypeRequiredDescription
serviceTokenIdstringYesPlanetScale service token ID
serviceTokenstringYesPlanetScale service token secret
organizationstringYesPlanetScale organization slug
databasestringYesThe name of the deploy request's database
deployRequestNumbernumberYesThe number of the deploy request

Output

ParameterTypeDescription
deployRequestjsonDeployRequest details
↳ idstringThe ID of the deploy request
↳ numbernumberThe number of the deploy request
↳ branchstringThe name of the branch the deploy request was created from
↳ intoBranchstringThe name of the branch the deploy request will be merged into
↳ statestringWhether the deploy request is open or closed
↳ deploymentStatestringThe deployment state of the deploy request
↳ approvedbooleanWhether or not the deploy request is approved
↳ numCommentsnumberThe number of comments on the deploy request
↳ notesstringNotes on the deploy request
↳ createdAtstringWhen the deploy request was created
↳ updatedAtstringWhen the deploy request was last updated
↳ closedAtstringWhen the deploy request was closed
↳ deployedAtstringWhen the deploy request was deployed
↳ htmlUrlstringThe PlanetScale app address for the deploy request

PlanetScale Create Deploy Request

Create a deploy request (Vitess only)

Input

ParameterTypeRequiredDescription
serviceTokenIdstringYesPlanetScale service token ID
serviceTokenstringYesPlanetScale service token secret
organizationstringYesPlanetScale organization slug
databasestringYesThe name of the deploy request's database
branchstringYesThe name of the branch the deploy request is created from
intoBranchstringYesThe name of the branch the deploy request will be merged into
notesstringNoNotes about the deploy request
autoCutoverbooleanNoWhether or not to enable auto_cutover for the deploy request. When enabled, will auto cutover to the new schema as soon as it is ready.
autoDeleteBranchbooleanNoWhether or not to enable auto_delete_branch for the deploy request. When enabled, will delete the branch once the DR successfully completes.

Output

ParameterTypeDescription
deployRequestjsonDeployRequest details
↳ idstringThe ID of the deploy request
↳ numbernumberThe number of the deploy request
↳ branchstringThe name of the branch the deploy request was created from
↳ intoBranchstringThe name of the branch the deploy request will be merged into
↳ statestringWhether the deploy request is open or closed
↳ deploymentStatestringThe deployment state of the deploy request
↳ approvedbooleanWhether or not the deploy request is approved
↳ numCommentsnumberThe number of comments on the deploy request
↳ notesstringNotes on the deploy request
↳ createdAtstringWhen the deploy request was created
↳ updatedAtstringWhen the deploy request was last updated
↳ closedAtstringWhen the deploy request was closed
↳ deployedAtstringWhen the deploy request was deployed
↳ htmlUrlstringThe PlanetScale app address for the deploy request

PlanetScale Review Deploy Request

Review a deploy request (Vitess only)

Input

ParameterTypeRequiredDescription
serviceTokenIdstringYesPlanetScale service token ID
serviceTokenstringYesPlanetScale service token secret
organizationstringYesPlanetScale organization slug
databasestringYesThe name of the database the deploy request belongs to
deployRequestNumbernumberYesThe number of the deploy request
statestringNoWhether the review is a comment or approval. Service tokens must have corresponding access (either approve_deploy_request or review_deploy_request)
bodystringNoDeploy request review comments

Output

ParameterTypeDescription
reviewjsonReview details
↳ idstringThe ID of the review
↳ statestringWhether the review is a comment or approval
↳ bodystringThe text body of the review
↳ createdAtstringWhen the review was created
↳ updatedAtstringWhen the review was last updated

PlanetScale Queue Deploy Request

Queue a deploy request (Vitess only)

Input

ParameterTypeRequiredDescription
serviceTokenIdstringYesPlanetScale service token ID
serviceTokenstringYesPlanetScale service token secret
organizationstringYesPlanetScale organization slug
databasestringYesThe name of the deploy request's database
deployRequestNumbernumberYesThe number of the deploy request
instantDdlbooleanNoWhether or not to deploy the request with instant DDL. Defaults to false.

Output

ParameterTypeDescription
deployRequestjsonDeployRequest details
↳ idstringThe ID of the deploy request
↳ numbernumberThe number of the deploy request
↳ branchstringThe name of the branch the deploy request was created from
↳ intoBranchstringThe name of the branch the deploy request will be merged into
↳ statestringWhether the deploy request is open or closed
↳ deploymentStatestringThe deployment state of the deploy request
↳ approvedbooleanWhether or not the deploy request is approved
↳ numCommentsnumberThe number of comments on the deploy request
↳ notesstringNotes on the deploy request
↳ createdAtstringWhen the deploy request was created
↳ updatedAtstringWhen the deploy request was last updated
↳ closedAtstringWhen the deploy request was closed
↳ deployedAtstringWhen the deploy request was deployed
↳ htmlUrlstringThe PlanetScale app address for the deploy request

PlanetScale Close Deploy Request

Close a deploy request (Vitess only)

Input

ParameterTypeRequiredDescription
serviceTokenIdstringYesPlanetScale service token ID
serviceTokenstringYesPlanetScale service token secret
organizationstringYesPlanetScale organization slug
databasestringYesThe name of the deploy request's database
deployRequestNumbernumberYesThe number of the deploy request

Output

ParameterTypeDescription
deployRequestjsonDeployRequest details
↳ idstringThe ID of the deploy request
↳ numbernumberThe number of the deploy request
↳ branchstringThe name of the branch the deploy request was created from
↳ intoBranchstringThe name of the branch the deploy request will be merged into
↳ statestringWhether the deploy request is open or closed
↳ deploymentStatestringThe deployment state of the deploy request
↳ approvedbooleanWhether or not the deploy request is approved
↳ numCommentsnumberThe number of comments on the deploy request
↳ notesstringNotes on the deploy request
↳ createdAtstringWhen the deploy request was created
↳ updatedAtstringWhen the deploy request was last updated
↳ closedAtstringWhen the deploy request was closed
↳ deployedAtstringWhen the deploy request was deployed
↳ htmlUrlstringThe PlanetScale app address for the deploy request