Source Database Setup
Configure your backend database for PowerSync
Postgres
Version compatibility: PowerSync requires Postgres version 11 or greater.
Configuring your Postgres database with PowerSync generally involves three tasks:
- Enable logical replication
- Create a PowerSync database user
- Create
powersync
publication
We have documented steps for some hosting providers:
For other providers and self-hosted databases:
Unsupported Hosted Postgres Providers
Due to the logical replication requirement, not all hosting providers are supported.
Notably, some “serverless Postgres” providers do not support logical replication, and are therefore not supported by PowerSync yet.
MongoDB (Alpha)
Version compatibility: PowerSync requires MongoDB version 6.0 or greater.
Permissions required - MongoDB Atlas
For MongoDB Atlas databases, the minimum permissions are:
To allow PowerSync to automatically configure enable changeStreamPreAndPostImages
on
replicated collections, instead use:
If you are replicating from multiple databases in the cluster, you need read permissions on the entire cluster:
Permissions required - Self-hosted
For self-hosted MongoDB, PowerSync requires the find
and changeStream
permissions on the database being replicated.
PowerSync also requires createCollection
, dropCollection
, insert
, update
, and remove
permissions to the _powersync_checkpoints
collection.
Post-Images
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
: UsesfullDocument: 'updateLookup'
for backwards compatibility. This was the default for older instances. However, this may lead to consistency issues, so we strongly recommend enabling postImages support instead. -
post_images: auto_configure
[Default for new instances]: Automatically configures thechangeStreamPreAndPostImages
option on collections as needed. -
post_images: read_only
: UsesfullDocument: 'required'
and requireschangeStreamPreAndPostImages: { enabled: true }
to be set on every collection referenced in sync rules. Replication will error if this is not configured. 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:
- To manually configure collections for
MySQL (Alpha)
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 Step
Next, connect PowerSync to your database:
Self-hosting: If you are self-hosting PowerSync, refer to PowerSync Service Setup next.
Was this page helpful?