Configure your backend database for PowerSync, including permissions and replication settings.
Jump to: Postgres | MongoDB | MySQL
Version compatibility: PowerSync requires Postgres version 11 or greater.
Configuring your Postgres database for PowerSync generally involves three tasks:
powersync
logical replication publicationWe have documented steps for some hosting providers:
Supabase
Supabase has logical replication enabled by default — no action required.
To restrict read access to specific tables, explicitly list allowed tables for both the SELECT
privilege, and for the publication mentioned in the next step (as well as for any other publications that may exist).
AWS RDS
The instance must be publicly accessible using an IPv4 address.
Access may be restricted to specific IPs if required — see IP Filtering.
Set the rds.logical_replication
parameter to 1
in the parameter group for the instance:
Create a PowerSync user on Postgres:
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).
Azure Postgres
PowerSync supports both “Azure Database for PostgreSQL” and “Azure Database for PostgreSQL Flexible Server”.
The database must be accessible on the public internet. Once you have created your database, navigate to Settings → Networking and enable Public access.
Follow the steps as noted in this Microsoft article to allow logical replication.
To restrict read access to specific tables, explicitly list allowed tables for both the SELECT
privilege, and for the publication mentioned in the next step (as well as for any other publications that may exist).
Google Cloud SQL
In Google Cloud SQL Postgres, enabling the logical replication is done using flags:
To restrict read access to specific tables, explicitly list allowed tables for both the SELECT
privilege, and for the publication mentioned in the next step (as well as for any other publications that may exist).
Neon
Neon is a serverless Postgres environment with an innovative pricing model that separates storage and compute.
To enable logical replication:
To restrict read access to specific tables, explicitly list allowed tables for both the SELECT
privilege, and for the publication mentioned in the next step (as well as for any other publications that may exist).
Fly Postgres
Fly Postgres is a Fly app with flyctl sugar on top to help you bootstrap and manage a database cluster for your apps.
Once you’ve deployed your Fly Postgres cluster, you can use the following command to enable logical replication:
To restrict read access to specific tables, explicitly list allowed tables for both the SELECT
privilege, and for the publication mentioned in the next step (as well as for any other publications that may exist).
PlanetScale
wal_level = logical
is required and PlanetScale has this set by default - no action needed.
To restrict read access to specific tables, explicitly list allowed tables for both the SELECT
privilege, and for the publication mentioned in the next step (as well as for any other publications that may exist).
For other providers and self-hosted databases:
Other / Self-hosted
Need help? Simply contact us on Discord and we’ll help you get set up.
PowerSync reads the Postgres WAL using logical replication in order to create sync buckets in accordance with the specified PowerSync Sync Rules.
If you are managing Postgres yourself, set wal_level = logical
in your config file:
Alternatively, you can use the below SQL commands to check and enable logical replication:
Note that Postgres must be restarted after changing this config.
If you’re using a managed Postgres service, there may be a setting for this in the relevant section of the service’s admin console.
To restrict read access to specific tables, explicitly list allowed tables for both the SELECT
privilege, and for the publication mentioned in the next step (as well as for any other publications that may exist).
Due to the logical replication requirement, not all Postgres hosting providers are supported. Notably, some “serverless Postgres” providers do not support logical replication, and are therefore not supported by PowerSync yet.
Version compatibility: PowerSync requires MongoDB version 6.0 or greater.
For MongoDB Atlas databases, the minimum permissions when using built-in roles are:
To allow PowerSync to automatically enable changeStreamPreAndPostImages
on replicated collections (the default for new PowerSync instances), additionally add the dbAdmin
permission:
If you are replicating from multiple databases in the cluster, you need read permissions on the entire cluster, in addition to the above:
For self-hosted MongoDB, or for creating custom roles on MongoDB Atlas, PowerSync requires the following privileges/granted actions:
listCollections
changeStream
collection: ""
db: ""
find
_powersync_checkpoints
collection: createCollection
, dropCollection
, find
, changeStream
, insert
, update
, and remove
changeStreamPreAndPostImages
on
replicated collections, additionally add the collMod
permission on all replicated collections.To replicate data from MongoDB to PowerSync in a consistent manner, PowerSync uses Change Streams with post-images to get the complete document after each change.
This requires the changeStreamPreAndPostImages
option to be enabled on replicated collections.
PowerSync supports three configuration options for post-images:
post_images: off
): Uses fullDocument: 'updateLookup'
for backwards compatibility. This was the default for older instances. However, this may lead to consistency issues, so we strongly recommend enabling post-images instead.post_images: auto_configure
) The default for new instances: Automatically enables the changeStreamPreAndPostImages
option on collections as needed. Requires the permissions/privileges mentioned above. If a collection is removed from Sync Rules, developers can manually disable changeStreamPreAndPostImages
.post_images: read_only
): Uses fullDocument: 'required'
and requires changeStreamPreAndPostImages: { enabled: true }
to be set on every collection referenced in the Sync Rules. Replication will error if this is not configured. This option is ideal when permissions are restricted.To manually configure collections for read_only
mode, run this on each collection:
You can view which collections have the option enabled using:
Post-images can be configured for PowerSync instances as follows:
Configure the Post Images setting in the connection configuration in the Dashboard (right-click on your instance to edit it).
Configure post_images
in the config.yaml
file.
If you need to use private endpoints with MongoDB Atlas, see Private Endpoints (AWS only).
For more information on migrating from Atlas Device Sync to PowerSync, see our migration guide.
This section is a work in progress. More details for MySQL connections are coming soon. In the meantime, ask on our Discord server if you have any questions.
Version compatibility: PowerSync requires MySQL version 5.7 or greater.
MySQL connections use the binary log to replicate changes.
Generally, this requires the following config:
gtid_mode
: ON
enforce_gtid_consistency
: ON
binlog_format
: ROW
PowerSync also requires a user with replication permissions on the database. An example:
Next, connect PowerSync to your database:
Refer to Database Connection.
Refer to PowerSync Service Setup in the Self-Hosting section.
Configure your backend database for PowerSync, including permissions and replication settings.
Jump to: Postgres | MongoDB | MySQL
Version compatibility: PowerSync requires Postgres version 11 or greater.
Configuring your Postgres database for PowerSync generally involves three tasks:
powersync
logical replication publicationWe have documented steps for some hosting providers:
Supabase
Supabase has logical replication enabled by default — no action required.
To restrict read access to specific tables, explicitly list allowed tables for both the SELECT
privilege, and for the publication mentioned in the next step (as well as for any other publications that may exist).
AWS RDS
The instance must be publicly accessible using an IPv4 address.
Access may be restricted to specific IPs if required — see IP Filtering.
Set the rds.logical_replication
parameter to 1
in the parameter group for the instance:
Create a PowerSync user on Postgres:
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).
Azure Postgres
PowerSync supports both “Azure Database for PostgreSQL” and “Azure Database for PostgreSQL Flexible Server”.
The database must be accessible on the public internet. Once you have created your database, navigate to Settings → Networking and enable Public access.
Follow the steps as noted in this Microsoft article to allow logical replication.
To restrict read access to specific tables, explicitly list allowed tables for both the SELECT
privilege, and for the publication mentioned in the next step (as well as for any other publications that may exist).
Google Cloud SQL
In Google Cloud SQL Postgres, enabling the logical replication is done using flags:
To restrict read access to specific tables, explicitly list allowed tables for both the SELECT
privilege, and for the publication mentioned in the next step (as well as for any other publications that may exist).
Neon
Neon is a serverless Postgres environment with an innovative pricing model that separates storage and compute.
To enable logical replication:
To restrict read access to specific tables, explicitly list allowed tables for both the SELECT
privilege, and for the publication mentioned in the next step (as well as for any other publications that may exist).
Fly Postgres
Fly Postgres is a Fly app with flyctl sugar on top to help you bootstrap and manage a database cluster for your apps.
Once you’ve deployed your Fly Postgres cluster, you can use the following command to enable logical replication:
To restrict read access to specific tables, explicitly list allowed tables for both the SELECT
privilege, and for the publication mentioned in the next step (as well as for any other publications that may exist).
PlanetScale
wal_level = logical
is required and PlanetScale has this set by default - no action needed.
To restrict read access to specific tables, explicitly list allowed tables for both the SELECT
privilege, and for the publication mentioned in the next step (as well as for any other publications that may exist).
For other providers and self-hosted databases:
Other / Self-hosted
Need help? Simply contact us on Discord and we’ll help you get set up.
PowerSync reads the Postgres WAL using logical replication in order to create sync buckets in accordance with the specified PowerSync Sync Rules.
If you are managing Postgres yourself, set wal_level = logical
in your config file:
Alternatively, you can use the below SQL commands to check and enable logical replication:
Note that Postgres must be restarted after changing this config.
If you’re using a managed Postgres service, there may be a setting for this in the relevant section of the service’s admin console.
To restrict read access to specific tables, explicitly list allowed tables for both the SELECT
privilege, and for the publication mentioned in the next step (as well as for any other publications that may exist).
Due to the logical replication requirement, not all Postgres hosting providers are supported. Notably, some “serverless Postgres” providers do not support logical replication, and are therefore not supported by PowerSync yet.
Version compatibility: PowerSync requires MongoDB version 6.0 or greater.
For MongoDB Atlas databases, the minimum permissions when using built-in roles are:
To allow PowerSync to automatically enable changeStreamPreAndPostImages
on replicated collections (the default for new PowerSync instances), additionally add the dbAdmin
permission:
If you are replicating from multiple databases in the cluster, you need read permissions on the entire cluster, in addition to the above:
For self-hosted MongoDB, or for creating custom roles on MongoDB Atlas, PowerSync requires the following privileges/granted actions:
listCollections
changeStream
collection: ""
db: ""
find
_powersync_checkpoints
collection: createCollection
, dropCollection
, find
, changeStream
, insert
, update
, and remove
changeStreamPreAndPostImages
on
replicated collections, additionally add the collMod
permission on all replicated collections.To replicate data from MongoDB to PowerSync in a consistent manner, PowerSync uses Change Streams with post-images to get the complete document after each change.
This requires the changeStreamPreAndPostImages
option to be enabled on replicated collections.
PowerSync supports three configuration options for post-images:
post_images: off
): Uses fullDocument: 'updateLookup'
for backwards compatibility. This was the default for older instances. However, this may lead to consistency issues, so we strongly recommend enabling post-images instead.post_images: auto_configure
) The default for new instances: Automatically enables the changeStreamPreAndPostImages
option on collections as needed. Requires the permissions/privileges mentioned above. If a collection is removed from Sync Rules, developers can manually disable changeStreamPreAndPostImages
.post_images: read_only
): Uses fullDocument: 'required'
and requires changeStreamPreAndPostImages: { enabled: true }
to be set on every collection referenced in the Sync Rules. Replication will error if this is not configured. This option is ideal when permissions are restricted.To manually configure collections for read_only
mode, run this on each collection:
You can view which collections have the option enabled using:
Post-images can be configured for PowerSync instances as follows:
Configure the Post Images setting in the connection configuration in the Dashboard (right-click on your instance to edit it).
Configure post_images
in the config.yaml
file.
If you need to use private endpoints with MongoDB Atlas, see Private Endpoints (AWS only).
For more information on migrating from Atlas Device Sync to PowerSync, see our migration guide.
This section is a work in progress. More details for MySQL connections are coming soon. In the meantime, ask on our Discord server if you have any questions.
Version compatibility: PowerSync requires MySQL version 5.7 or greater.
MySQL connections use the binary log to replicate changes.
Generally, this requires the following config:
gtid_mode
: ON
enforce_gtid_consistency
: ON
binlog_format
: ROW
PowerSync also requires a user with replication permissions on the database. An example:
Next, connect PowerSync to your database:
Refer to Database Connection.
Refer to PowerSync Service Setup in the Self-Hosting section.