Fly Postgres

Instructions for configuring PowerSync on a Fly Postgres instance. Fly Postgres is a Fly app with flyctl sugar on top to help you bootstrap and manage a database cluster for your apps.

Enable Logical Replication

Once you've deployed your Fly Postgres cluster, it's time to enable logical replication.

This is performed by running the below command:

fly pg config update --wal-level=logical

Create a PowerSync Database User

Create a PowerSync user on Postgres:

-- SQL to create powersync user
CREATE ROLE powersync_role WITH REPLICATION LOGIN PASSWORD 'myhighlyrandompassword';
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO powersync_role;

For read-only access, only the SELECT privilege is required — INSERT, UPDATE and DELETE can be removed.

To restrict read access to specific tables, explicitly list allowed tables for both the SELECT privilege, and for the publication (as well as for any other publications that may exist).

Create "powersync" Publication

-- Create publication to replicate tables. Specify a subset of tables if required.
-- NOTE: this must be named "powersync" at the moment
CREATE PUBLICATION powersync FOR ALL TABLES;

Connect PowerSync to Fly Postgres

Complete the instructions documented here to connect the PowerSync Service to your Fly Postgres cluster:

Last updated