As I just answered on your related preceding question I recommend not to use the public
schema for your objects at all. Reserve it for extensions like PostGis and use one or more separate schemas for your objects.
The public schema is in no way different than any other schema in your database. PostgreSQL does not need it at all. It just happens to be the default schema where many extensions put their stuff. So put your stuff somewhere else and set the search_path
where you need it.
Then you can also create corresponding users with a matching preset search_path
. The basic setup could look something like this:
CREATE ROLE sales;
ALTER ROLE sales SET search_path=sales, public; -- postgis functions in public?
COMMENT ON ROLE sales IS 'Sales app uses this user to connect.';
CREATE ROLE sales_admin;
ALTER ROLE sales_admin SET search_path=sales, public;
COMMENT ON ROLE sales_admin IS 'Owns objects in schema sales.';
CREATE SCHEMA sales;
GRANT ALL ON SCHEMA sales TO sales_admin;
GRANT USAGE ON SCHEMA sales TO sales;
COMMENT ON SCHEMA sales IS 'All objects for my sales app here.'
You'll also be interested in DEFAULT PRIVILEGES
for users or schemas. More under this closely related question:
Grant all on a specific schema in the db to a group role in PostgreSQL