The docker-compose stack provisions one Postgres instance with a database per
service (dante_auth, dante_billing, dante_registry, dante_scheduler,
dante_storage). The init script created these via a PL/pgSQL function that ran
`EXECUTE 'CREATE DATABASE ...'`, but PostgreSQL forbids CREATE DATABASE inside a
function or transaction block. dante_auth already exists (POSTGRES_DB) so it was
skipped, but the first real creation (dante_billing) raised:
ERROR: CREATE DATABASE cannot be executed from a function
leaving billing/registry/scheduler/storage uncreated. Their services then failed
to connect ("failed to connect user=dante_user"), exactly as reported in #3.
Rewrote the script to use the canonical psql \gexec pattern, which runs each
generated CREATE DATABASE outside any transaction, guarded by NOT EXISTS for
idempotency, plus an ALTER DATABASE OWNER pass for pre-existing databases.
Verified against a throwaway PostgreSQL 15 cluster: the old script errors on
dante_billing and leaves only dante_auth; the new script creates all five
databases and completes cleanly.