MM setup issue on naked Ubuntu 24.04 LTS with postgres

I’ve completely reset the server and did everything again. Same issue persisted. When checking the logs, it seemed to be a postgres access issue with:

Error: failed to initialize platform: cannot create store: failed to apply database migrations: pq: permission denied for schema public
{"timestamp":"2024-08-23 12:15:43.090 Z","level":"error","msg":"failed to initialize platform: cannot create store: failed to apply database migrations: pq: permission denied for schema public","caller":"commands/server.go:76"}

That was resolved by:

Thanks to Alexander this is solved.
for PSQL 15 you need extra grants for the user:

GRANT ALL ON DATABASE mattermost TO mmuser;
ALTER DATABASE mattermost OWNER TO mmuser;
GRANT USAGE, CREATE ON SCHEMA PUBLIC TO mmuser;