<!-- llms.txt: https://workos.com/llms.txt -->
<!-- feedback.md: https://workos.com/docs/feedback.md -->

# PlanetScale

## Introduction

[PlanetScale](https://planetscale.com) hosts Postgres and Vitess, a MySQL-compatible database. The sync engine connects through each engine's standard protocol using `@workos/sync-postgres` or `@workos/sync-mysql`.

The [PlanetScale integration guide](https://github.com/workos/sync-engine/blob/main/docs/integrations/planetscale.md) in the sync engine repository covers database creation, roles, connection strings, TLS, endpoint verification, and deployment.

## Sync to Postgres

Follow the [Postgres guide](https://workos.com/docs/events/data-syncing/database/postgres) with your PlanetScale connection string as `DATABASE_URL`. The sync needs a role that can create the mirror's schema and objects; the default read/write role is not enough for initialization.

Keep `sslmode=verify-full`, but remove `sslrootcert=system` from PlanetScale's connection string when using the Node.js driver. See the repository's [Postgres setup](https://github.com/workos/sync-engine/blob/main/docs/integrations/planetscale.md#postgres) for the role, connection options, TLS behavior, and commands.

## Sync to Vitess

Use the [MySQL destination](https://workos.com/docs/events/data-syncing/database/mysql), with two PlanetScale-specific considerations:

- **The branch is the database.** Set `WORKOS_SYNC_SCHEMA` to the branch's database name rather than letting the sync create a separate `workos` database.
- **Safe migrations control schema changes.** On a protected production branch, apply the mirror's schema through a PlanetScale deploy request rather than running DDL directly.

Follow the repository's [Vitess setup](https://github.com/workos/sync-engine/blob/main/docs/integrations/planetscale.md#vitess-mysql) for credentials, the required TLS CA configuration, and the safe-migrations workflow. The [`@workos/sync-mysql` README](https://github.com/workos/sync-engine/blob/main/packages/sync-mysql/README.md) is the reference for commands and configuration.

## Branches and queries

Each branch needs its own credentials and mirror initialization. Syncs sharing a WorkOS environment also share its API rate limit. See [Branches](https://github.com/workos/sync-engine/blob/main/docs/integrations/planetscale.md#branches) before setting up additional mirrors.

Query the mirror's `_live` views to exclude deleted objects. See [Query it](https://github.com/workos/sync-engine/blob/main/docs/integrations/planetscale.md#query-it) for Postgres and Vitess examples.
