I'm trying to deploy Mantis BT on Heroku, using PostgreSQL as the database, as a proof of concept and learning exercise (or perhaps more accurately, as a "climb up a steep learning curve," since I'm a total newbie to all three technologies).
The deploy of the PHP app to Heroku went fine, and accessing the app's URL brings up its admin/install.php
page. Provisioning the PostgreSQL database went fine, and gave me a database URL that (obfuscated) looks like this:
postgres://useruseruser:passwordpasswordpassword@ec2-107-21-219-201.compute-1.amazonaws.com:5432/dbnamedbname
I'm able to access the database via psql
using those credentials, and the user (predictably) doesn't have the 'usecreatedb' privilege. I can't really make sense of the output of the PostgreSQL \z
command, which seems to say I have no privileges on a table I've created:
dbnamedbname=> \z foo;
Access privileges
Schema | Name | Type | Access privileges | Column access privileges
--------+------+-------+-------------------+--------------------------
public | foo | table | |
(1 row)
but I put that impression down to not really knowing PostgreSQL's idioms yet.
Empirically I've been able to determine that I have the privileges CREATE (for both tables & indexes), SELECT, INSERT, UPDATE, DELETE, ALTER and DROP, which seem to be what Mantis BT requires for its "high-privileged database account."
So, it would seem that I have everything I need to fill in the Mantis BT admin/install.php
form:
Two notes here:
Yet, when I fill in the form using the values above and click the "Install/Upgrade Database" button, I get a failure indicating that the app could not connect to the database with the credentials provided (the exact same credentials, BTW, that I used to connect to the database using psql
):
(One suspicious thing in the above screenshot -- that I haven't yet steeled myself to go hunting for in the code: the obscured Admin password in the page returned by the form submission only shows six bullets, whereas the actual password I pasted was 30 characters long.)
So, questions to anyone who understands how Mantis BT database setup works.
The "Database connection failed" results from an initial connection attempt in which no database name is specified.
Attempting to access the server in this way from psql
causes the following error:
$ psql -h ec2-107-21-219-102.compute-1.amazonaws.com -U useruseruser
Password for user useruseruser:
psql: FATAL: database "useruseruser" does not exist
Adding the database name as an additional parameter to that Connect()
call causes the connection attempt to succeed, and thereafter all table creation steps and checks succeed.
It's not clear to me whether the problem is with PostgreSQL 9.4.5 per se, or whether it's something in how Heroku in particular configures their PostgreSQL servers.
Issue filed: https://www.mantisbt.org/bugs/view.php?id=20589
So, with the code patched, the answers to the questions I asked are:
As a bonus answer, it's apparently not possible to create a lower-privileged user in a Heroku-provisioned PostgreSQL database -- you're stuck with the one user they give you. Which kinda sucks.