Search overlay panel for performing site-wide searches

Build Your Next Big Thing on Heroku. Sign Up Now!

Introducing Managed Logical Replication Support for Heroku Postgres Advanced

Logical replication is now available for all Heroku Postgres Advanced databases. You can use it to send ongoing row changes from a publisher database to a subscriber database, or to receive changes from an external Postgres database.

This is one of the most requested capabilities from Heroku Postgres customers. You asked for a way to keep databases in sync during a version upgrade or migration. You also need logical replication to build real-time data flows and to integrate with systems that consume Postgres changes. We built this support so you can use these Postgres patterns while Heroku continues to manage your database service.

How to use managed logical replication for your Heroku Postgres Advanced databases

You can create publications and subscriptions on a Postgres Advanced database:

  • Publisher: Your Heroku database sends row changes to a subscriber database.
  • Subscriber: Your Heroku database receives row changes from another Postgres publisher.

After you enable publishing, you can create and manage publications with the Heroku CLI. A publication defines the tables or schemas that Postgres sends to subscribers.

You can publish:

  • A selected list of tables.
  • All eligible tables in one or more schemas.
  • All current customer schemas.

For example, enable your source database for publishing and create a publication for all the tables in the public schema of your database:

heroku data:pg:logical-replication:publishing:enable DATABASE --app example-app

# Wait for the database update to complete, then:
heroku data:pg:logical-replication:publications:create DATABASE \
  --name application_pub \
  --schema public \
  --app example-app

To connect an external subscriber, retrieve the dedicated publisher connection URL and use it to create a Postgres subscription on the target database:

heroku data:pg:credentials:url DATABASE --name publisher --app example-app

The subscriber database needs matching schemas and tables before it receives changes. This is standard Postgres behavior. Logical replication sends row changes; it does not copy DDL or sequence state.

Built for controlled, self-service operation

Logical replication reads row changes from the Postgres write-ahead log (WAL). The publisher decodes the changes and sends them to subscribers. A replication slot tracks each subscriber’s progress.

You manage the replication topology. Heroku manages the service controls that enable the feature and protect the database service.

Heroku enables logical replication through an asynchronous database update. You can track the update with heroku data:pg:info.

  • Enabling publishing creates a separate publisher credential with only the privileges needed for replication.
  • Enabling subscribing grants the database owner the Postgres permission to create subscriptions.

The CLI manages publications instead of asking you to run CREATE PUBLICATION directly. This protects Heroku-managed roles and schemas, and it verifies that a publication belongs to the database that you selected.

Plan your replication topology

Logical replication is a Postgres feature, so its normal operating rules apply:

  • Create the subscriber schema and tables before you create the subscription.
  • Repeat schema changes on each subscriber. Logical replication doesn’t replicate CREATE, ALTER, or DROP statements.
  • Set sequence values on the target as part of a migration or cutover plan. Sequence state is not replicated.
  • Ensure published tables have a primary key or suitable replica identity if you replicate updates or deletes.
  • Monitor replication slots and retained WAL pending to replicate. A disconnected subscriber can cause the publisher to retain WAL until the subscriber reconnects or you remove the slot.

Built from customer feedback

The request for logical replication has been clear. Customers have told us that they need it to reduce downtime during Postgres upgrades, to move data between disaster recovery or ETL systems, and to support real-time change consumers. The public Heroku roadmap request describes these needs directly.

This release is part of our continued work to deliver the platform capabilities that help you build, deploy, and scale production applications without operational friction. We will continue to innovate on Heroku Postgres, delivering the features you ask for and the foundations you need to succeed on the Heroku Platform.

Get started with managed logical replication

Logical replication is generally available in every Heroku region and on plans that support Heroku Postgres Advanced databases. Start by upgrading the Heroku CLI to version 11.11.0 or later, then enable your Postgres Advanced database to start publishing or subscribing to data changes..

Read the logical replication guide for prerequisites, setup steps, and operational guidance.

Ready to Get Started?

Stay focused on building great data-driven applications and let Heroku tackle the rest.

Talk to A Heroku Rep   Sign Up Now

More from the Author
Software Engineering Architect at Heroku
Heroku Staff

Browse the archives for News or all blogs. Subscribe to the RSS feed for News or all blogs.