Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aeMoF-0002OQ-6y for pgsql-admin@arkaria.postgresql.org; Fri, 11 Mar 2016 13:08:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aeMoE-0004pp-J5 for pgsql-admin@arkaria.postgresql.org; Fri, 11 Mar 2016 13:08:50 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aeMoD-0004pN-RR for pgsql-admin@postgresql.org; Fri, 11 Mar 2016 13:08:49 +0000 Received: from plane.gmane.org ([80.91.229.3]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1aeMo9-0001c6-UL for pgsql-admin@postgresql.org; Fri, 11 Mar 2016 13:08:48 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1aeMny-0003Zs-Oz for pgsql-admin@postgresql.org; Fri, 11 Mar 2016 14:08:34 +0100 Received: from 185.40.248.10 ([185.40.248.10]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 11 Mar 2016 14:08:34 +0100 Received: from spam_eater by 185.40.248.10 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 11 Mar 2016 14:08:34 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-admin@postgresql.org From: Thomas Kellerer Subject: Re: Separate DDL and SQL users Date: Fri, 11 Mar 2016 14:08:27 +0100 Lines: 31 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 185.40.248.10 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 In-Reply-To: X-Pg-Spam-Score: 0.3 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org Rob Emery schrieb am 11.03.2016 um 12:18: > So we're looking at automating our migrations against PG for the > developers so that it's simple enough for them and no maintenance for > me. I'm struggling to find a role/permissions structure that works; > we've come from SQL Server so we're used to having DBRoles. > > So I want the re_migration role to be able to create tables, > sequences etc and grant to other users etc; yet I want the > live_application role to be able to select,insert,update,delete. > > It seems that the only real solution here is to have the db owned by > re_migration, then in every migration GRANT > SELECT,INSERT,UPDATE,DELETE to the live_application role? You can set default privileges for a schema: http://www.postgresql.org/docs/current/static/sql-alterdefaultprivileges.html If you do that, every object that is created in the schema is automatically assigned those default privileges. So you only need to do do once, after you create a new schema, e.g. as re_migration do: create schema dbo; grant usage on dbo to life_application; alter default privileges in schema dbo grant select,insert,update,delete on tables to live_application; alter default privileges in schema dbo grant usage,select,update on sequences to live_application; Of course the re_migration role needs to have the privileges to create a schema. Thomas -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin