diff --git a/installation/database-setup.mdx b/installation/database-setup.mdx index 0b9459bd..ef6560a6 100644 --- a/installation/database-setup.mdx +++ b/installation/database-setup.mdx @@ -54,7 +54,7 @@ We have documented steps for some hosting providers: ![](/images/setup-2.png) - + ### 2. Create a PowerSync database user Create a PowerSync user on Postgres: @@ -62,10 +62,10 @@ We have documented steps for some hosting providers: ```sql -- SQL to create powersync user CREATE ROLE powersync_role WITH BYPASSRLS LOGIN PASSWORD 'myhighlyrandompassword'; - + -- Allow the role to perform replication tasks GRANT rds_replication TO powersync_role; - + -- Set up permissions for the newly created role -- Read-only (SELECT) access is required GRANT SELECT ON ALL TABLES IN SCHEMA public TO powersync_role; @@ -168,10 +168,10 @@ We have documented steps for some hosting providers: ```sql -- Create a publication to replicate tables. -- PlanetScale does not support ON ALL TABLES so - -- Specify each table you want to sync + -- Specify each table you want to sync -- The publication must be named "powersync" CREATE PUBLICATION powersync - FOR TABLE public.lists, public.todos; + FOR TABLE public.lists, public.todos; ``` @@ -195,11 +195,11 @@ For other providers and self-hosted databases: ```sql -- Check the replication type - + SHOW wal_level; - + -- Ensure logical replication is enabled - + ALTER SYSTEM SET wal_level = logical; ``` @@ -254,13 +254,13 @@ readAnyDatabase@admin For self-hosted MongoDB, or for creating custom roles on MongoDB Atlas, PowerSync requires the following privileges/granted actions: - On the database being replicated: `listCollections` -- On all collections in the database: `changeStream` - - This must apply to the entire database, not individual collections. Specify `collection: ""` - - If replicating from multiple databases, this must apply to the entire cluster. Specify `db: ""` -- On each collection being replicated: `find` +- On the database and any collections being replicated: `find` +- On the database and any collections being replicated: `changeStream` + - This must apply to the entire database, not individual collections. Specify `collection: ""` or by checking the `Apply to any collection` checkbox in the MongoDB Atlas. + - If replicating from multiple databases, this must apply to the entire cluster. Specify `db: ""` or by checking the `Apply to any database` checkbox in MongoDB Atlas. - On the `_powersync_checkpoints` collection: `createCollection`, `dropCollection`, `find`, `changeStream`, `insert`, `update`, and `remove` - To allow PowerSync to automatically enable [`changeStreamPreAndPostImages`](#post-images) on - replicated collections, additionally add the `collMod` permission on all replicated collections. + replicated collections, additionally add the `collMod` permission on the database and all collections being replicated. ### Post-Images @@ -352,4 +352,4 @@ Next, connect PowerSync to your database: Refer to **PowerSync Service Setup** in the Self-Hosting section. - \ No newline at end of file +