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
Configuring your Postgres database with PowerSync generally involves three tasks:
14
17
15
-
* Enable logical replication
16
-
17
-
* Create a PowerSync database user
18
-
19
-
* Create `powersync` publication
18
+
1. Enable logical replication
19
+
2. Create a PowerSync database user
20
+
3. Create `powersync` publication
20
21
21
22
We have documented steps for some hosting providers:
22
23
@@ -28,17 +29,11 @@ We have documented steps for some hosting providers:
28
29
29
30
### 2. Create a PowerSync Database User
30
31
31
-
It is not currently possible to create a new user on Supabase with replication permissions without contacting their support. Instead, use the default `postgres` user.
32
+
<PostgresPowerSyncUser />
32
33
33
34
### 3. Create "powersync" Publication
34
35
35
-
The `postgres` user does not have access to create a publication for all tables. Instead, list each table explicitly.
36
-
37
-
This can also be done on the Supabase dashboard in the database *Replication* page.
38
-
39
-
```sql
40
-
CREATE PUBLICATION powersync FOR TABLE public.lists, public.todos;
41
-
```
36
+
<PostgresPowerSyncPublication />
42
37
</Accordion>
43
38
44
39
<Accordiontitle="AWS RDS">
@@ -66,32 +61,21 @@ We have documented steps for some hosting providers:
66
61
67
62
```sql
68
63
-- SQL to create powersync user
69
-
70
64
CREATE ROLE powersync_role WITH LOGIN PASSWORD 'myhighlyrandompassword';
71
65
72
66
-- Allow the role to perform replication tasks
73
-
74
67
GRANT rds_replication TO powersync_role;
75
68
76
69
-- Set up permissions for the newly created role
77
-
78
-
GRANTSELECT, INSERT, UPDATE, DELETEON ALL TABLES IN SCHEMA public TO powersync_role;
79
-
70
+
-- Read-only (SELECT) access is required
71
+
GRANTSELECTON ALL TABLES IN SCHEMA public TO powersync_role;
80
72
```
81
73
82
-
For read-only access, only the `SELECT` privilege is required — `INSERT`, `UPDATE` and `DELETE` can be removed.
83
-
84
74
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).
85
75
86
76
### 3. Create "powersync" Publication
87
77
88
-
```sql
89
-
-- Create publication to replicate tables. Specify a subset of tables if required.
90
-
91
-
-- NOTE: this must be named "powersync" at the moment
92
-
93
-
CREATE PUBLICATION powersync FOR ALL TABLES;
94
-
```
78
+
<PostgresPowerSyncPublication />
95
79
</Accordion>
96
80
97
81
<Accordiontitle="Azure Postgres">
@@ -109,34 +93,11 @@ We have documented steps for some hosting providers:
109
93
110
94
### 2. Create a PowerSync Database User
111
95
112
-
Create a PowerSync user on Postgres:
113
-
114
-
```sql
115
-
-- SQL to create powersync user
116
-
117
-
CREATE ROLE powersync_role WITH REPLICATION LOGIN PASSWORD 'myhighlyrandompassword';
118
-
119
-
GRANTSELECT, INSERT, UPDATE, DELETEON ALL TABLES IN SCHEMA public TO powersync_role;
120
-
121
-
```
122
-
123
-
For read-only access, only the `SELECT` privilege is required — `INSERT`, `UPDATE` and `DELETE` can be removed.
124
-
125
-
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).
96
+
<PostgresPowerSyncUser />
126
97
127
98
### 3. Create "powersync" Publication
128
99
129
-
```sql
130
-
-- Create publication to replicate tables. Specify a subset of tables if required.
131
-
132
-
-- NOTE: this must be named "powersync" at the moment
133
-
134
-
CREATE PUBLICATION powersync FOR ALL TABLES;
135
-
136
-
-- Example for specifying a subset of tables:
137
-
138
-
-- CREATE PUBLICATION powersync FOR table users, projects, user_projects, checklists;
139
-
```
100
+
<PostgresPowerSyncPublication />
140
101
</Accordion>
141
102
142
103
<Accordiontitle="Google Cloud SQL">
@@ -150,30 +111,11 @@ We have documented steps for some hosting providers:
150
111
151
112
### 2. Create a PowerSync Database User
152
113
153
-
Create a PowerSync user on Postgres:
154
-
155
-
```sql
156
-
-- SQL to create powersync user
157
-
158
-
CREATE ROLE powersync_role WITH REPLICATION LOGIN PASSWORD 'myhighlyrandompassword';
159
-
160
-
GRANTSELECT, INSERT, UPDATE, DELETEON ALL TABLES IN SCHEMA public TO powersync_role;
161
-
162
-
```
163
-
164
-
For read-only access, only the `SELECT` privilege is required — `INSERT`, `UPDATE` and `DELETE` can be removed.
165
-
166
-
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).
114
+
<PostgresPowerSyncUser />
167
115
168
116
### 3. Create "powersync" Publication
169
117
170
-
```sql
171
-
-- Create publication to replicate tables. Specify a subset of tables if required.
172
-
173
-
-- NOTE: this must be named "powersync" at the moment
174
-
175
-
CREATE PUBLICATION powersync FOR ALL TABLES;
176
-
```
118
+
<PostgresPowerSyncPublication />
177
119
</Accordion>
178
120
179
121
<Accordiontitle="Neon">
@@ -189,29 +131,11 @@ We have documented steps for some hosting providers:
189
131
190
132
### 2. Create a PowerSync Database User
191
133
192
-
Create a PowerSync user on Postgres:
193
-
194
-
```sql
195
-
-- SQL to create powersync user
196
-
197
-
CREATE ROLE powersync_role WITH REPLICATION LOGIN PASSWORD 'myhighlyrandompassword';
198
-
199
-
GRANTSELECT, INSERT, UPDATE, DELETEON ALL TABLES IN SCHEMA public TO powersync_role;
200
-
```
201
-
202
-
For read-only access, only the `SELECT` privilege is required — `INSERT`, `UPDATE` and `DELETE` can be removed.
203
-
204
-
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).
134
+
<PostgresPowerSyncUser />
205
135
206
136
### 3. Create "powersync" Publication
207
137
208
-
```sql
209
-
-- Create publication to replicate tables. Specify a subset of tables if required.
210
-
211
-
-- NOTE: this must be named "powersync" at the moment
212
-
213
-
CREATE PUBLICATION powersync FOR ALL TABLES;
214
-
```
138
+
<PostgresPowerSyncPublication />
215
139
</Accordion>
216
140
217
141
<Accordiontitle="Fly Postgres">
@@ -233,29 +157,11 @@ We have documented steps for some hosting providers:
233
157
234
158
### 2. Create a PowerSync Database User
235
159
236
-
Create a PowerSync user on Postgres:
237
-
238
-
```sql
239
-
-- SQL to create powersync user
240
-
241
-
CREATE ROLE powersync_role WITH REPLICATION LOGIN PASSWORD 'myhighlyrandompassword';
242
-
243
-
GRANTSELECT, INSERT, UPDATE, DELETEON ALL TABLES IN SCHEMA public TO powersync_role;
244
-
```
245
-
246
-
For read-only access, only the `SELECT` privilege is required — `INSERT`, `UPDATE` and `DELETE` can be removed.
247
-
248
-
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).
160
+
<PostgresPowerSyncUser />
249
161
250
162
### 3. Create "powersync" Publication
251
163
252
-
```sql
253
-
-- Create publication to replicate tables. Specify a subset of tables if required.
254
-
255
-
-- NOTE: this must be named "powersync" at the moment
256
-
257
-
CREATE PUBLICATION powersync FOR ALL TABLES;
258
-
```
164
+
<PostgresPowerSyncPublication />
259
165
</Accordion>
260
166
</AccordionGroup>
261
167
@@ -292,29 +198,11 @@ For other providers and self-hosted databases:
292
198
293
199
### 2. Create a PowerSync Database User
294
200
295
-
Create a PowerSync user on Postgres:
296
-
297
-
```sql
298
-
-- SQL to create powersync user
299
-
300
-
CREATE ROLE powersync_role WITH REPLICATION LOGIN PASSWORD 'myhighlyrandompassword';
301
-
302
-
GRANTSELECT, INSERT, UPDATE, DELETEON ALL TABLES IN SCHEMA public TO powersync_role;
303
-
```
304
-
305
-
For read-only access, only the `SELECT` privilege is required — `INSERT`, `UPDATE` and `DELETE` can be removed.
306
-
307
-
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).
201
+
<PostgresPowerSyncUser />
308
202
309
203
### 3. Create "powersync" Publication
310
204
311
-
```sql
312
-
-- Create publication to replicate tables. Specify a subset of tables if required.
313
-
314
-
-- NOTE: this must be named "powersync" at the moment
Used in conjunction with **FlutterFlow**, PowerSync enables developers to build local-first apps that are robust in poor network conditions and that have highly responsive frontends while relying on Supabase for their backend. This guide walks you through configuring PowerSync within your FlutterFlow project that has Supabase integration enabled.
11
13
@@ -68,11 +70,7 @@ This guide walks you through building a basic item management app from scratch a
68
70
## Configure Supabase
69
71
70
72
1. Create a new project in Supabase.
71
-
72
-
2. PowerSync uses the Postgres [Write Ahead Log (WAL)](https://www.postgresql.org/docs/current/wal-intro.html) to replicate data changes in order to keep PowerSync SDK clients up to date.
73
-
74
-
3. Run the below SQL statement in your **Supabase SQL Editor**:
75
-
73
+
2. To set up the Postgres database for our demo app, we will create a `lists` table. The demo app will have access to this table even while offline. Run the below SQL statement in your **Supabase SQL Editor**:
76
74
```sql
77
75
create table
78
76
public.lists (
@@ -84,20 +82,10 @@ This guide walks you through building a basic item management app from scratch a
84
82
constraint lists_owner_id_fkey foreign key (owner_id) referencesauth.users (id) on delete cascade
85
83
) tablespace pg_default
86
84
```
87
-
85
+
3. PowerSync uses the Postgres [Write Ahead Log (WAL)](https://www.postgresql.org/docs/current/wal-intro.html) to replicate data changes in order to keep PowerSync SDK clients up to date. Run the below SQL statement in your **Supabase SQL Editor** to create a Postgres role/user with replication privileges:
86
+
<PostgresPowerSyncUser />
88
87
4. Create a Postgres publication using the SQL Editor. This will enable data to be replicated from Supabase so that your FlutterFlow app can download it.
89
-
90
-
```sql
91
-
create publication powersync for table public.lists;
92
-
```
93
-
94
-
<Note>
95
-
This is a static list of tables. If you add additional tables to your schema, they must also be added to this publication.
96
-
</Note>
97
-
98
-
<Info>
99
-
This guide uses the default `postgres` user in your Supabase account for replicating changes to PowerSync, since elevating custom roles to replication [has been disabled](https://github.com/orgs/supabase/discussions/9314) in Supabase. If you want to use a custom role for this purpose, contact the Supabase support team.
<Framecaption="Video walkthrough of the integration guide.">
11
13
<iframewidth="1005"height="420"src="https://www.youtube.com/embed/Xg5FTYGPn5U?si=4TjdYEACDR2g98yh"title="YouTube video player"frameborder="0"
@@ -48,7 +50,7 @@ We will follow these steps to get an offline-first 'To-Do List' demo app up and
48
50
<Steps>
49
51
<Steptitle="Configure Supabase:">
50
52
* Create the demo database schema
51
-
* Create the Postgres publication
53
+
* Create the Postgres user and publication
52
54
</Step>
53
55
<Steptitle="Configure PowerSync:">
54
56
* Create connection to Supabase
@@ -67,7 +69,7 @@ Create a new Supabase project (or use an existing project if you prefer) and fol
67
69
68
70
To set up the Postgres database for our _To-Do List_ demo app, we will create two new tables: `lists` and `todos`. The demo app will have access to these tables even while offline.
69
71
70
-
Run the below SQL statements in your **Supabase SQL Editor**: (if you get a warning about a "potentially destructive operation", that's a false positive that you can safely ignore.)
72
+
Run the below SQL statements in your **Supabase SQL Editor**:
71
73
72
74
```sql
73
75
create table
@@ -97,21 +99,20 @@ create table
97
99
) tablespace pg_default;
98
100
```
99
101
100
-
### Create the Postgres Publication
102
+
### Create a PowerSync Database User
101
103
102
104
PowerSync uses the Postgres [Write Ahead Log (WAL)](https://www.postgresql.org/docs/current/wal-intro.html) to replicate data changes in order to keep PowerSync SDK clients up to date.
103
105
104
-
Run the below SQL statement in your **Supabase SQL Editor**:
106
+
Run the below SQL statement in your **Supabase SQL Editor** to create a Postgres role/user with replication privileges:
105
107
106
-
```sql
107
-
-- Create publication for powersync
108
+
<PostgresPowerSyncUser />
108
109
109
-
create publication powersync for table public.lists, public.todos;
110
-
```
110
+
### Create the Postgres Publication
111
+
112
+
Run the below SQL statement in your **Supabase SQL Editor** to create a Postgres publication:
113
+
114
+
<PostgresPowerSyncPublication />
111
115
112
-
<Info>
113
-
**Note:** this guide uses the default `postgres` user in your Supabase account for replicating changes to PowerSync, since elevating custom roles to replication [has been disabled](https://github.com/orgs/supabase/discussions/9314) in Supabase. If you want to use a custom role for this purpose, contact the Supabase support team.
-- Create a role/user with replication privileges for PowerSync
3
+
CREATE ROLE powersync_role WITH REPLICATION LOGIN PASSWORD 'myhighlyrandompassword';
4
+
-- Set up permissions for the newly created role
5
+
-- Read-only (SELECT) access is required
6
+
GRANTSELECTON ALL TABLES IN SCHEMA public TO powersync_role;
7
+
```
8
+
9
+
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).
0 commit comments