Google Cloud SQL

Instructions for configuring PowerSync for an Google Cloud SQL Postgres database.

Enable Logical Replication

In Google Cloud SQL Postgres, enabling the logical replication is done using flags:

Create a PowerSync Database User

Create a PowerSync user on Postgres:

-- SQL to create powersync user
CREATE ROLE powersync_role WITH REPLICATION LOGIN PASSWORD 'myhighlyrandompassword';
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO powersync_role;

For read-only access, only the SELECT privilege is required — INSERT, UPDATE and DELETE can be removed.

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).

Create "powersync" Publication

-- Create publication to replicate tables. Specify a subset of tables if required.
-- NOTE: this must be named "powersync" at the moment
CREATE PUBLICATION powersync FOR ALL TABLES;

Connect PowerSync to Your Database

  1. In the PowerSync dashboard project tree, click on "Create new instance":

  1. Give your instance a name, such as "GCP Testing".

  2. Under the "General" tab, you can change the default cloud region from US to EU or JP if desired (more cloud regions are available, contact us if you need a different region).

  3. Under the "DB Connections" tab, click on the + icon.

  4. Now we get the connection details from Google Cloud SQL:

    • The server certificate can be downloaded from Google Cloud SQL.

    • If SSL is enforced, a client certificate and key must also be created on Google Cloud SQL, and configured on the PowerSync instance.

    • The Username and Password is the powersync_role created above.

  5. Click "Test Connection" and fix any errors.

  6. Click "Save".

  7. PowerSync deploys and configures an isolated cloud environment for you, which will take a few minutes to complete.

Last updated