PowerSync Docs
Search
⌃K

Database Setup

Configuring your database with PowerSync involves three tasks:

Enable Write Ahead Logging (WAL)

PowerSync reads the WAL in order to create sync tables in accordance with the specified sync rules. For more info on sync rules, see this section.
If you are managing PostgreSQL yourself, set wal_level = logical in your config file:
If you're using managed PostgreSQL, enable it in the relevant section of the admin console. Amazon RDS is shown below.

Create a PowerSync Database User

Create a PowerSync user on PostgreSQL:
-- 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;
-- 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;
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).

Configure PowerSync Cloud Service

During the developer preview this is managed for you by the PowerSync team, reach out to us to get this set up. In the future you will be able to configure this from the PowerSync cloud admin console.