Required Permissions

For Stacksync to sync data from/to your Postgres, Stacksync requires a given set of permissions. These are the least minimal permissions require for Stacksync to work.

When creating a Postgres sync on Stacksync Dashboard, you will need to provide a DB user. Here is a guide to create a user with the least permissions while still enabling Stacksync Syncs from/to your Postgres DB.

Here is the list of queries you need to execute in your Postgres DB to create and grant the db user stacksync_user the necessary permissions.

You need to replace the following fields in the query:

  • '<PROVIDE_STRONG_PASSWORD>'

  • '<SCHEMA_NAME_CONTAINING_THE_TABLES_YOU_WANT_TO_SYNC>'

  • '<NAMES_OF_TABLES_YOU_WANT_TO_SYNC>'

CREATE USER stacksync_user WITH PASSWORD '<PROVIDE_STRONG_PASSWORD>';
--necessary to create tables
CREATE SCHEMA IF NOT EXISTS stacksync_logging;
GRANT ALL PRIVILEGES ON SCHEMA stacksync_logging TO stacksync_user;

--necessary to create triggers on table you want to sync
GRANT CREATE ON DATABASE postgres TO stacksync_user;
GRANT USAGE, CREATE ON SCHEMA '<SCHEMA_NAME_CONTAINING_THE_TABLES_YOU_WANT_TO_SYNC>' TO stacksync_user;
GRANT USAGE ON LANGUAGE plpgsql TO stacksync_user;
GRANT SELECT, TRIGGER ON TABLE '<NAMES_OF_TABLES_YOU_WANT_TO_SYNC>' TO stacksync_user;

-- necessary to detect which tables can be synced by Stacksync
GRANT SELECT ON pg_class TO stacksync_user;
GRANT SELECT ON pg_namespace TO stacksync_user;
GRANT SELECT ON pg_constraint TO stacksync_user;
GRANT SELECT ON pg_attribute TO stacksync_user;
GRANT SELECT ON pg_attrdef TO stacksync_user;
GRANT SELECT ON information_schema.sequences TO stacksync_user;

Last updated