Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qg7fM-00EW2P-Nj for pgsql-novice@arkaria.postgresql.org; Tue, 12 Sep 2023 17:59:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qg7fL-009zEV-0r for pgsql-novice@arkaria.postgresql.org; Tue, 12 Sep 2023 17:59:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qg7fK-009zE8-Ku for pgsql-novice@lists.postgresql.org; Tue, 12 Sep 2023 17:59:10 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qg7fG-004h2b-P9 for pgsql-novice@lists.postgresql.org; Tue, 12 Sep 2023 17:59:09 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-99c1c66876aso757947266b.2 for ; Tue, 12 Sep 2023 10:59:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20230601.gappssmtp.com; s=20230601; t=1694541544; x=1695146344; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=f6QLzughmsAxlWqMUgs9KG//9DtlQh0r+IWpp3DsmIA=; b=nP74u30zc0dSXzty31B3Y4sShQW1tDDSxZEb9des+0pDHCiiWVjzWWzlrbkc7iy5Mx h4ZNwFzpPReI2fWpBIkbsy2tcW68qQcgf6XwooFyg1JfpRC8KSfjbjUvyMVPg81vaTWE jTaClaFsRwoRFmdnbTbhtBNwRiuNtwRdZw1HQaz2m35IyrmmrwbCVev/RJJml66UAyaz Itmt6YV7SA1RD52InZdKMzORxRMX+iVGqEjkAq5bVlZ+IHQuHeoGQ++hXoICdPAdu3xO 3TFjwB3iFcdanz9onmGMjyTcfYnCmsaEKiIH9/A4llCw8REKFRnZfqpWgRh6d3PenL2j LqEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694541544; x=1695146344; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=f6QLzughmsAxlWqMUgs9KG//9DtlQh0r+IWpp3DsmIA=; b=VxGvDGqhDBNwhpeSWq6KUuF5KdNDY6NBT6RYInPMb78AIYSwrJ0aAeTUHAVrqMuAco rwYHupEII/D26At/sTb9ztcLaFQ95xc1XC8xnTZ20VkcFy8bAmTe7F8jnvH6cJf4mkX8 1/NZzUGpdJYwcLf9kquJ72Xa/Yat/+/pIkVvOB3Kqwdl3/VtX4j3jPIDuHwA4XApOgkv hKP3GMept5511TAxcEJ86nkv+6yJVir5JJI+wR5AAG8xTbvHqZ2AWOkj9TjrtfKlU1oS 8kZDteSEkPEXsc5qwoEXVNkYKJ1EB0HjDpk5TAyEnM1Fc1IWVkxnQ7NcWPsG88NxfHvt n1uw== X-Gm-Message-State: AOJu0YxaXikR8rVtYILAmuhfpUyuh9GK5yCYso8Mw4nNvz5QjP3np2bC eM3dK5KY42ARykFRyi7r+UK3HSaEuB+Q4oS8bHQ= X-Google-Smtp-Source: AGHT+IFXPzJW7r9pWhchJQ97Pdlt6N9WKPcnG9KC6EnpypwbMU5tgffRTzToDx0FIw4b0MOf8LS2uQ== X-Received: by 2002:a17:907:270f:b0:99c:f47a:2354 with SMTP id w15-20020a170907270f00b0099cf47a2354mr28225ejk.70.1694541544627; Tue, 12 Sep 2023 10:59:04 -0700 (PDT) Received: from localhost.localdomain (178-190-169-82.adsl.highway.telekom.at. [178.190.169.82]) by smtp.gmail.com with ESMTPSA id v14-20020a17090690ce00b0099c53c44083sm7136380ejw.79.2023.09.12.10.59.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 10:59:04 -0700 (PDT) Message-ID: <72494a1f44ffee61199cabd104a278d4ff30c4e1.camel@cybertec.at> Subject: Re: Grant CREATE privilege on all schemas From: Laurenz Albe To: ivanov17@riseup.net, Pgsql Novice Date: Tue, 12 Sep 2023 19:59:03 +0200 In-Reply-To: <42a7db124fa2f9685f01c0a80161549c@riseup.net> References: <42a7db124fa2f9685f01c0a80161549c@riseup.net> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2023-09-12 at 17:38 +0000, ivanov17@riseup.net wrote: > Thank you for your answer. Unfortunately, I'm not even a junior DBA, so > I might be misunderstanding something. =D0=A1an I ask more questions? >=20 > Typically, for each of my websites, I create one database, one database > owner role, and its private schema. And I want to have a role that can > to access each private schema to create tables and write data to provide > database migrations. >=20 > I can't know what schema I need to create tomorrow, so I think it's > reasonable to grant privileges to the migration role in advance. But > maybe I don't need predefined roles at all. >=20 > Now I see that I might to have another problem because tables should be > created by migration role, but after that they must be fully accessible > to the database owner. I think I also need to grant full default > privileges to the database/schema owners on all tables created by the > migration role in their own schemas, right? >=20 > Also, when creating databases/schemas, I need to give the migration role > full default privileges to use private schemas, create tables in them, > and write data. In this case, I no longer need the predefined roles. >=20 > Does this sound like a good plan? Could you please correct me if there > is a better way to do this? The owner of the tables must be the user that creates them, that is your migration role. If the database and the schemas are owned by a different user, that does not matter, as long as the migration user has CREATE on all schemas. You could use ALTER DEFAULT PRIVILEGES to make sure that every schema created by the database owner has that required permission by default. While that should work fine, I deem it more complicated than necessary. I would opt for the migration user being the same as the database owner. Yours, Laurenz Albe