Sidekiq worker insufficient Postgres privileges

Hey @julianrubisch,

When a table is created it will receive an owner, which is typically the user who created the table.

\dt
              List of relations
 Schema | Name  | Type  |        Owner
--------+-------+-------+---------------------
 public | names | table | foo
 public | users | table | foo
(2 rows)

By default, no other standard users will be able to access the given table until permissions are explicitly granted.

There are a number of ways you could address this and it ultimately comes down to your requirements.
For example, if you want foo_worker to have access to everything within the public schema, you can run the following:

ALTER DEFAULT PRIVILEGES IN SCHEMA public
  GRANT SELECT, INSERT, UPDATE, DELETE ON tables TO foo_worker;

ALTER DEFAULT PRIVILEGES IN SCHEMA public
  GRANT SELECT, USAGE ON sequences TO foo_worker;

If you would prefer to give foo_worker specific privileges to a single table, you could run something like:

GRANT SELECT, UPDATE ON TABLE users TO foo_worker;

Note: The above commands can be run by the table owner or superuser.

This all being said, permissions can get quite complicated. We will have to think a bit about how we want to address this in the future.