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/database-setup.mdx
+27-44Lines changed: 27 additions & 44 deletions
Original file line number
Diff line number
Diff line change
@@ -37,37 +37,34 @@ We have documented steps for some hosting providers:
37
37
38
38
<PostgresPowerSyncPublication />
39
39
</Accordion>
40
-
41
40
<Accordiontitle="AWS RDS">
42
41
### Prerequisites
43
42
44
43
The instance must be publicly accessible using an IPv4 address.
45
44
46
45
<Frame>
47
-
<imgsrc="/images/setup-1.avif" />
46
+

48
47
</Frame>
49
-
50
48
Access may be restricted to specific IPs if required — see [IP Filtering](/installation/database-setup/security-and-ip-filtering).
51
49
52
50
### 1. Enable logical replication
53
51
54
52
Set the `rds.logical_replication` parameter to `1` in the parameter group for the instance:
55
53
56
54
<Frame>
57
-
<imgsrc="/images/setup-2.png" />
55
+

58
56
</Frame>
59
-
60
57
### 2. Create a PowerSync database user
61
58
62
59
Create a PowerSync user on Postgres:
63
60
64
61
```sql
65
62
-- SQL to create powersync user
66
63
CREATE ROLE powersync_role WITH BYPASSRLS LOGIN PASSWORD 'myhighlyrandompassword';
67
-
64
+
68
65
-- Allow the role to perform replication tasks
69
66
GRANT rds_replication TO powersync_role;
70
-
67
+
71
68
-- Set up permissions for the newly created role
72
69
-- Read-only (SELECT) access is required
73
70
GRANTSELECTON ALL TABLES IN SCHEMA public TO powersync_role;
@@ -79,7 +76,6 @@ We have documented steps for some hosting providers:
79
76
80
77
<PostgresPowerSyncPublication />
81
78
</Accordion>
82
-
83
79
<Accordiontitle="Azure Postgres">
84
80
PowerSync supports both "Azure Database for PostgreSQL" and "Azure Database for PostgreSQL Flexible Server".
85
81
@@ -99,16 +95,14 @@ We have documented steps for some hosting providers:
99
95
100
96
<PostgresPowerSyncPublication />
101
97
</Accordion>
102
-
103
98
<Accordiontitle="Google Cloud SQL">
104
99
### 1. Enable logical replication
105
100
106
101
In Google Cloud SQL Postgres, enabling the logical replication is done using flags:
107
102
108
103
<Frame>
109
-
<imgsrc="/images/setup-3.png" />
104
+

110
105
</Frame>
111
-
112
106
### 2. Create a PowerSync database user
113
107
114
108
<PostgresPowerSyncUser />
@@ -117,13 +111,13 @@ We have documented steps for some hosting providers:
117
111
118
112
<PostgresPowerSyncPublication />
119
113
</Accordion>
120
-
121
114
<Accordiontitle="Neon">
122
115
Neon is a serverless Postgres environment with an innovative pricing model that separates storage and compute.
123
116
124
117
### 1. Enable Logical Replication
125
118
126
-
To [enable logical replication](https://neon.tech/docs/guides/logical-replication-postgres#prepare-your-source-neon-database):
119
+
To [enable logical replication](https://neon.tech/docs/guides/logical-replication-postgres#prepare-your-source-neon-database):
120
+
127
121
1. Select your project in the Neon Console.
128
122
2. On the Neon Dashboard, select **Settings**.
129
123
3. Select **Logical Replication**.
@@ -137,7 +131,6 @@ We have documented steps for some hosting providers:
137
131
138
132
<PostgresPowerSyncPublication />
139
133
</Accordion>
140
-
141
134
<Accordiontitle="Fly Postgres">
142
135
Fly Postgres is a [Fly](https://fly.io/) app with [flyctl](https://fly.io/docs/flyctl/) sugar on top to help you bootstrap and manage a database cluster for your apps.
143
136
@@ -150,9 +143,8 @@ We have documented steps for some hosting providers:
150
143
```
151
144
152
145
<Frame>
153
-
<imgsrc="/images/setup-5.avif" />
146
+

154
147
</Frame>
155
-
156
148
### 2. Create a PowerSync database user
157
149
158
150
<PostgresPowerSyncUser />
@@ -175,18 +167,17 @@ For other providers and self-hosted databases:
175
167
If you are managing Postgres yourself, set `wal_level = logical` in your config file:
176
168
177
169
<Frame>
178
-
<imgsrc="/images/setup-6.avif" />
170
+

179
171
</Frame>
180
-
181
172
Alternatively, you can use the below SQL commands to check and enable logical replication:
182
173
183
174
```sql
184
175
-- Check the replication type
185
-
176
+
186
177
SHOW wal_level;
187
-
178
+
188
179
-- Enable logical replication
189
-
180
+
190
181
ALTER SYSTEM SET wal_level = logical;
191
182
```
192
183
@@ -215,7 +206,7 @@ Due to the logical replication requirement, not all Postgres hosting providers a
215
206
216
207
### Permissions required - MongoDB Atlas
217
208
218
-
For MongoDB Atlas databases, the minimum permissions are:
209
+
For MongoDB Atlas databases, the minimum permissions when using built-in roles are:
219
210
220
211
```
221
212
readWrite@<your_database>._powersync_checkpoints
@@ -240,15 +231,14 @@ readAnyDatabase@admin
240
231
241
232
For self-hosted MongoDB, or for creating custom roles on MongoDB Atlas, PowerSync requires the following privileges/granted actions:
242
233
243
-
* On the database being replicated: `listCollections`
244
-
* On all collections in the database: `changeStream`
245
-
* This must apply to the entire database, not individual collections. Specify `collection: ""`
246
-
* If replicating from multiple databases, this must apply to the entire cluster. Specify `db: ""`
247
-
* On each collection being replicated: `find`
248
-
* On the `_powersync_checkpoints` collection: `createCollection`, `dropCollection`, `find`, `changeStream`, `insert`, `update`, and `remove`
249
-
* To allow PowerSync to automatically enable [`changeStreamPreAndPostImages`](#post-images) on
250
-
replicated collections, additionally add the `collMod` permission on all replicated collections.
251
-
234
+
- On the database being replicated: `listCollections`
235
+
- On all collections in the database: `changeStream`
236
+
- This must apply to the entire database, not individual collections. Specify `collection: ""`
237
+
- If replicating from multiple databases, this must apply to the entire cluster. Specify `db: ""`
238
+
- On each collection being replicated: `find`
239
+
- On the `_powersync_checkpoints` collection: `createCollection`, `dropCollection`, `find`, `changeStream`, `insert`, `update`, and `remove`
240
+
- To allow PowerSync to automatically enable [`changeStreamPreAndPostImages`](#post-images) on
241
+
replicated collections, additionally add the `collMod` permission on all replicated collections.
252
242
253
243
### Post-Images
254
244
@@ -258,9 +248,7 @@ This requires the `changeStreamPreAndPostImages` option to be enabled on replica
258
248
PowerSync supports three configuration options for post-images:
259
249
260
250
1.**Off**: (`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.
261
-
262
251
2.**Automatic**: (`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](/usage/sync-rules), developers can manually disable `changeStreamPreAndPostImages`.
263
-
264
252
3.**Read-only**: (`post_images: read_only`): Uses `fullDocument: 'required'` and requires `changeStreamPreAndPostImages: { enabled: true }` to be set on every collection referenced in the [Sync Rules](/usage/sync-rules). Replication will error if this is not configured. This option is ideal when permissions are restricted.
265
253
266
254
To manually configure collections for `read_only` mode, run this on each collection:
@@ -282,23 +270,21 @@ Post-images can be configured for PowerSync instances as follows:
282
270
283
271
<CardGroup cols="2">
284
272
<Card title="PowerSync Cloud:">
285
-
Configure the **Post Images** setting in the connection configuration in the Dashboard (right-click on your instance to edit it).
273
+
Configure the **Post Images** setting in the connection configuration in the Dashboard (right-click on your instance to edit it).
286
274
</Card>
287
275
<Card title="Self-Hosted PowerSync:" href="https://github.com/powersync-ja/self-host-demo/blob/main/demos/nodejs-mongodb/config/powersync.yaml#L11" cta="See an example">
288
-
Configure `post_images` in the `config.yaml` file.
276
+
Configure `post_images` in the `config.yaml` file.
289
277
</Card>
290
278
</CardGroup>
291
279
292
280
### MongoDB Atlas private endpoints using AWS PrivateLink
293
281
294
282
If you need to use private endpoints with MongoDB Atlas, see [Private Endpoints](/installation/database-setup/private-endpoints) (AWS only).
295
283
296
-
297
284
### Migrating from MongoDB Atlas Device Sync
298
285
299
286
For more information on migrating from Atlas Device Sync to PowerSync, see our [migration guide](/migration-guides/mongodb-atlas).
300
287
301
-
302
288
## <Icon icon="dolphin" iconType="solid" size="24" /> MySQL (Alpha)
303
289
304
290
<Info>
@@ -313,11 +299,9 @@ MySQL connections use the [binary log](https://dev.mysql.com/doc/refman/8.4/en/b
313
299
314
300
Generally, this requires the following config:
315
301
316
-
* `gtid_mode` : `ON`
317
-
318
-
* `enforce_gtid_consistency` : `ON`
319
-
320
-
* `binlog_format` : `ROW`
302
+
- `gtid_mode` : `ON`
303
+
- `enforce_gtid_consistency` : `ON`
304
+
- `binlog_format` : `ROW`
321
305
322
306
PowerSync also requires a user with replication permissions on the database. An example:
323
307
@@ -346,5 +330,4 @@ Next, connect PowerSync to your database:
0 commit comments