CapyDB/ docs
GuidesImports & Migrations

Migrate from PlanetScale for Postgres

Move a PlanetScale Postgres database into CapyDB.

This is about PlanetScale for Postgres. A PlanetScale MySQL or Vitess database is a different migration - different storage engine, different type system, different SQL dialect - and not one CapyDB performs.

Get the source connection string

From the branch's connect dialog. PlanetScale Postgres hosts look like xxxxxxxxxx-useast1-1.horizon.psdb.cloud, and passwords are prefixed pscale_pw_.

postgres://role.branchid:pscale_pw_...@xxxxxxxxxx-useast1-1.horizon.psdb.cloud:5432/dbname?sslmode=require

Use port 5432, not 6432. Port 6432 is PSBouncer, which pools transactions - it cannot hold the session state a consistent dump needs, and it cannot open a replication slot. The CLI and the importer both refuse pooled endpoints for exactly this reason, so the error you get is actionable rather than a mid-import failure.

For a near-zero-downtime import

Confirm the branch has logical replication enabled and that the role you are connecting as can use it:

capydb migrate scan --source-url "$PLANETSCALE_DATABASE_URL"

The scan reports the server's own wal_level, the replication-slot budget and whether your role carries REPLICATION - which is the only reliable answer, since these are settings rather than fixed product properties.

Preflight and import

capydb import preflight --project your-project --source-url "$PLANETSCALE_DATABASE_URL"

capydb import --project your-project --source-url "$PLANETSCALE_DATABASE_URL" --follow
capydb import follow-status --project your-project
capydb import cutover --project your-project

What changes on the other side

  • Connection pooling is included. CapyDB gives every cell a pooled endpoint alongside the direct one, so the PSBouncer split maps across unchanged: pooled for the application, direct for migrations and dumps. See Connection pooling.
  • Branches become preview databases. A CapyDB preview is a storage clone of the cell with a time to live, one per pull request. See Previews.
  • Idle cells sleep. A cell with no connections pauses and wakes on the next one, typically inside a quarter of a second.

After the import

  1. \dx for extensions, and re-enable on the project anything the restore could not create.
  2. Spot-check sequences.
  3. ANALYZE;
  4. Swap the connection string in every consumer - capydb doctor catches environment files still pointing at the old host.