apps(farrisilk): close the metabase_ro schema-CREATE hole + README

metabase_ro could create tables in public: default_transaction_read_only is a
role default the role can lift (SET ... = off), and PG16 keeps CREATE on schema
public for PUBLIC when the database was created by a non-superuser (Odoo creates
its own). Revoke CREATE from PUBLIC and ALL from metabase_ro, grant USAGE only,
in both the first-boot script and the per-start grant pass. README documents the
stack, list_db/workers=0 rationale, module loading, filestore, the DB-only backup
gap (filestore is not covered; follow-up t_8bdd3708) and the Shopify blank.
This commit is contained in:
Lance Walters 2026-11-22 02:28:56 -05:00
commit f658bfabe9
3 changed files with 291 additions and 0 deletions

View file

@ -61,6 +61,11 @@ data:
# Schema-level setup in the (still empty) odoo database. Table grants and
# the credential-table revokes are (re)applied by the odoo initContainer.
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname odoo <<'EOSQL'
-- Odoo creates the `odoo` role's tables later; PUBLIC must not keep CREATE
-- on the public schema (PG16 keeps it when the database was made by a
-- non-superuser), or the "read-only" BI role can create tables after
-- lifting its own default_transaction_read_only.
REVOKE CREATE ON SCHEMA public FROM PUBLIC;
GRANT USAGE ON SCHEMA public TO metabase_ro;
ALTER DEFAULT PRIVILEGES FOR ROLE odoo IN SCHEMA public
GRANT SELECT ON TABLES TO metabase_ro;