You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: installation/app-backend-setup.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ When using PowerSync, your app backend is responsible for the following:
7
7
8
8
1. Authenticating app users
9
9
2.[Generating JWTs](/installation/authentication-setup) that allows the PowerSync Client SDK to authenticate users against the server-side [PowerSync Service](/architecture/powersync-service).
10
-
3.[Writing client-side changes](/installation/app-backend-setup/writing-client-changes) to the backend database (Postgresor MongoDB)
10
+
3.[Writing client-side changes](/installation/app-backend-setup/writing-client-changes) to the backend database (Postgres, MongoDB or MySQL)
11
11
12
12
<Framecaption="An overview of how PowerSync interacts with your backend application.">
Copy file name to clipboardExpand all lines: installation/app-backend-setup/writing-client-changes.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ In other words, don't place writes into something like a queue for processing la
20
20
</Warning>
21
21
22
22
<Accordiontitle="Why must my write endpoint be synchronous?">
23
-
Client applications advance to a write checkpoint after uploads have been processed, so if the client believes that the server has written changes into your backend database (Postgresor MongoDB), but the next checkpoint does not contain your uploaded changes, those changes will be removed from the client. This could manifest as UI glitches for your end-users, where the changes disappear from the device for a few seconds and then re-appear.
23
+
Client applications advance to a write checkpoint after uploads have been processed, so if the client believes that the server has written changes into your backend database (Postgres, MongoDB or MySQL), but the next checkpoint does not contain your uploaded changes, those changes will be removed from the client. This could manifest as UI glitches for your end-users, where the changes disappear from the device for a few seconds and then re-appear.
Copy file name to clipboardExpand all lines: installation/client-side-setup/integrating-with-your-backend.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ description: "The PowerSync 'backend connector' provides the connection between
7
7
It is used to:
8
8
9
9
1. Retrieve a JWT token which can be used by the PowerSync Client SDK to authenticate against your [PowerSync Service](/architecture/powersync-service) instance.
10
-
2. Upload writes to your backend: Writes that are made to the local SQLite database are sent to your backend application, where you control how they're applied to your backend database (Postgresor MongoDB)
10
+
2. Upload writes to your backend: Writes that are made to the local SQLite database are sent to your backend application, where you control how they're applied to your backend database (Postgres, MongoDB or MySQL)
11
11
12
12
Accordingly, the connector must implement two methods:
Copy file name to clipboardExpand all lines: self-hosting/installation/powersync-service-setup.mdx
+55-10Lines changed: 55 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,15 +3,15 @@ title: "PowerSync Service Setup"
3
3
description: "Configuration details for connecting the PowerSync Service to your database"
4
4
---
5
5
6
-
After configuring your Postgres database for PowerSync, you'll setup your [PowerSync Service](/architecture/powersync-service).
6
+
After configuring your source database for PowerSync, you'll need to setup your [PowerSync Service](/architecture/powersync-service).
7
7
8
8
This entails:
9
9
10
-
1. Configuring MongoDB (if required)
10
+
1. Configuring sync bucket storage
11
11
12
12
2. Defining your PowerSync config
13
13
14
-
1. Defining connections to Postgres and MongoDB
14
+
1. Defining connections to your source database, and sync bucket storage database
15
15
16
16
2. Defining your [Sync Rules](/usage/sync-rules)
17
17
@@ -23,9 +23,13 @@ Examples of the above can be found in our demo application [here](https://github
23
23
**Deploy PowerSync on Coolify:** See our [integration guide](/integration-guides/coolify) for deploying the PowerSync Service on Coolify. This can simplify the setup and management of the deployment.
24
24
</Tip>
25
25
26
-
## Configure MongoDB
26
+
## Configure Sync Bucket Storage
27
27
28
-
The PowerSync Service uses [MongoDB](https://www.mongodb.com/) under the hood and requires at least one replica set node. A single node is fine for development/staging environments, but a 3-node replicas set is recommended [for production](/self-hosting/lifecycle-maintenance/server-specs).
28
+
The PowerSync Service requires a storage backend for sync buckets. You can use either MongoDB or Postgres for this purpose. The storage backend is separate from your source database.
29
+
30
+
### MongoDB Storage
31
+
32
+
MongoDB requires at least one replica set node. A single node is fine for development/staging environments, but a 3-node replica set is recommended [for production](/self-hosting/lifecycle-maintenance/server-specs).
29
33
30
34
[MongoDB Atlas](https://www.mongodb.com/products/platform/atlas-database) enables replica sets by default for new clusters.
31
35
@@ -50,6 +54,36 @@ If you are rolling your own Docker environment, you can include this init script
Available since version 1.3.8 of [`journeyapps/powersync-service`](https://hub.docker.com/r/journeyapps/powersync-service), you can use Postgres as an alternative storage backend for sync buckets. This feature is currently in [beta](/resources/feature-status).
60
+
61
+
#### Database Setup
62
+
63
+
You'll need to create a dedicated user and schema for PowerSync storage. You can either:
64
+
65
+
1. Let PowerSync create the schema (recommended):
66
+
67
+
```sql
68
+
CREATE USER powersync_storage_user WITH PASSWORD 'secure_password';
69
+
-- The user should only have access to the schema it created
70
+
GRANT CREATE ON DATABASE postgres TO powersync_storage_user;
71
+
```
72
+
73
+
2. Or manually create the schema:
74
+
75
+
```sql
76
+
CREATE USER powersync_storage_user WITH PASSWORD 'secure_password';
77
+
CREATE SCHEMA IF NOT EXISTS powersync AUTHORIZATION powersync_storage_user;
78
+
GRANT CONNECT ON DATABASE postgres TO powersync_storage_user;
79
+
GRANT USAGE ON SCHEMA powersync TO powersync_storage_user;
80
+
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA powersync TO powersync_storage_user;
81
+
```
82
+
83
+
<Tip>
84
+
**Demo app:** A demo app with Postgres bucket storage is available [here](https://github.com/powersync-ja/self-host-demo/tree/main/demos/nodejs-postgres-bucket-storage).
85
+
</Tip>
86
+
53
87
## PowerSync Configuration
54
88
55
89
The PowerSync Service is configured using key/value pairs in a config file, and supports the following configuration methods:
@@ -70,7 +104,7 @@ The config file schema is also available here:
70
104
71
105
<Card title="self-host-demo/schema/schema.json at main · powersync-ja/self-host-demoGitHub" icon="github" href="https://github.com/powersync-ja/self-host-demo/blob/main/schema/schema.json" horizontal />
72
106
73
-
Below is a skeleton config file that you can copy/paste and edit locally:
107
+
Below is a skeleton config file you can copy and paste to edit locally:
74
108
75
109
```yaml
76
110
# config.yaml
@@ -90,16 +124,23 @@ replication:
90
124
91
125
# SSL settings
92
126
sslmode: disable # 'verify-full' (default) or 'verify-ca' or 'disable'
93
-
# 'disable' is OK for local/private networks, not for public networks
127
+
# Note: 'disable' is only suitable for local/private networks, not for public networks
94
128
95
-
# Connection settings for sync bucket storage
129
+
# Connection settings for sync bucket storage (MongoDB and Postgres are supported)
96
130
storage:
131
+
# Option 1: MongoDB Storage
97
132
type: mongodb
98
133
uri: mongodb://mongo:27017/powersync_demo
99
-
# use these if authentication is required
134
+
# Use these if authentication is required. The user should have `readWrite` and `dbAdmin` roles
100
135
# username: myuser
101
136
# password: mypassword
102
137
138
+
# Option 2: Postgres Storage
139
+
# type: postgresql
140
+
# This accepts the same parameters as a Postgres replication source connection
# The port which the PowerSync API server will listen on
104
145
port: 80
105
146
@@ -132,6 +173,10 @@ client_auth:
132
173
133
174
```
134
175
176
+
<Info>
177
+
**Important:** When using Postgres for sync bucket storage, a separate server is currently required for replication connections (if using Postgres for replication) and storage. Using the same server might cause unexpected results.
178
+
</Info>
179
+
135
180
Specify the connection to Postgres in the `replication` section. Retrieving your database connection string / individual parameters differs by database hosting provider. See [Database Connection](/self-hosting/appendix/database-connection) for further details.
136
181
137
182
<Info>
@@ -142,7 +187,7 @@ Specify the connection to Postgres in the `replication` section. Retrieving your
142
187
This is because Supabase only allows direct database connections over IPv6 — PowerSync cannot connect using the connection pooler.
143
188
</Info>
144
189
145
-
Specify the connection to MongoDB in the `storage` section.
190
+
Specify the connection to your sync bucket storage provider (Postgres or MongoDB) in the `storage` section.
Copy file name to clipboardExpand all lines: usage/sync-rules.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ The remainder of these docs dive further into the details.
15
15
16
16
Each [PowerSync Service](/architecture/powersync-service) instance has a Sync Rules configuration where Sync Rules are defined using SQL-like queries (limitations and more info [here](/usage/sync-rules/operators-and-functions)) combined together in a YAML file.
17
17
18
-
This SQL-like syntax is used when connecting to either Postgresor MongoDB as the backend source database.
18
+
This SQL-like syntax is used when connecting to either Postgres, MongoDB or MySQL as the backend source database.
19
19
20
20
The [PowerSync Service](/architecture/powersync-service) uses these SQL-like queries to group data into "sync buckets" when replicating data to client devices.
0 commit comments