Skip to main content
This page covers PlanetScale for Postgres. For PlanetScale on Vitess (MySQL), use the PlanetScale source connector.
This page covers only what differs on PlanetScale. For partitioned tables, tables without primary keys, and other settings, see the PostgreSQL overview.

Create a service account

Connect to the primary as the branch’s default postgres role on port 5432 and run:
setup.sql
  • Connect as artie_transfer.<branch_id>. The branch ID is the part after the . in the default username (e.g. postgres.nk35mx55qq).
  • SQL-created roles don’t appear on the PlanetScale Roles page. A managed role can only get WITH REPLICATION by inheriting postgres (admin), so this role is the least-privileged option.

Create the heartbeat table

Heartbeats keep the slot advancing on a quiet branch, which matters on PlanetScale because max_slot_wal_keep_size defaults to no limit. As postgres, run:
heartbeats.sql
Grant to artie_transfer without the branch suffix. The table must be in the publication, which the next step covers. Then turn on Enable heartbeats under Postgres settings.

Create a publication

Artie can’t create publications on PlanetScale, so create one as postgres. Without it, deployment fails with publication "dbz_publication" does not exist. Once a table is in a publication, PostgreSQL rejects UPDATE and DELETE on it unless it has a primary key or replica identity. First, list tables that would break:
check.sql
If it returns tables, set REPLICA IDENTITY FULL on each (details) or publish only specific tables (below). To replicate a table without a primary key, also set Override primary keys in Artie to an existing unique index, or Artie fails with partition key is not set. Then create the publication and leave the pipeline’s publication mode on All tables:
publication.sql
This includes tables created later, so give every new table a primary key or replica identity.
Create the publication with a table list instead, and include the heartbeat table if you use heartbeats:
Set the pipeline’s publication mode to Filtered. If you already created the FOR ALL TABLES publication, drop it first (DROP PUBLICATION dbz_publication;), or deployment fails with please set the publication mode to 'all tables'. Add new tables before adding them to the pipeline:

Enable logical replication

In the PlanetScale console, go to your branch’s Clusters → Parameters and set:

Create a failover-safe replication slot

A slot only survives a PlanetScale switchover or failover if it has failover = true. If PlanetScale finds a logical slot without it, it notifies you and resumes planned failovers after three days. Before you deploy, enable Use PostgreSQL 17 failover replication slot under Postgres settings. Artie then creates its slot with failover. The setting doesn’t change an existing slot.
As artie_transfer, before deploying:
slot.sql
Use your slot name override instead of artie if you set one. Keep the failover setting on so Artie recreates the slot with failover if it’s ever dropped.
After deploying, check that failover is t:
If it’s f, see Repairing a slot created without failover below.

Connect Artie to PlanetScale

Artie enables TLS automatically, which PlanetScale requires. Under Postgres settings, turn on Publish partitioned table changes via partition root to match the publication, or deployment fails validation.
Connect directly to the primary on port 5432. Don’t use the PgBouncer port (6432) or append |replica to the username.

Advanced

You can enable failover on an existing slot without dropping it (PlanetScale’s procedure). sync_replication_slots and hot_standby_feedback must be on first.
1

Pause the pipeline

Choose Pause reading & delivery so the reader releases the slot (the default, Pause delivery only, stays connected). For a shared source reader, contact Artie support to pause it.
2

Open a replication connection as the default role

3

Alter the slot

If it hangs, a session is still attached. From a normal (non-replication) postgres connection, run:
4

Verify and resume

Confirm failover is t in pg_replication_slots, then resume the pipeline. Artie continues from its last acknowledged position.
PlanetScale switches over for parameter changes, resizes, and upgrades, and fails over if the primary goes down. With the settings above, the slot moves to the new primary and Artie resumes from its last acknowledged position after a brief gap.
Each branch is its own cluster and doesn’t inherit parameters, SQL-created roles, publications, or slots. Repeat these steps on that branch and create a separate Artie source with its credentials.
PlanetScale supports AWS PrivateLink. Otherwise, Artie connects from its fixed IP addresses.