Grafana install fails when recent version of PostgreSQL is used as backend

The most recent minor releases of PostgreSQL (11.4, 10.9, 9.6.14, 9.5.18, 9.4.23) introduced a bug that causes an error when Grafana is initially started and tries to create its schema in PostgreSQL. The issue was narrowed down to this statement that the Grafana install tries to run:

ALTER TABLE “user” ALTER “login” TYPE VARCHAR(190), ALTER “email” TYPE
VARCHAR(190), ALTER “name” TYPE VARCHAR(255), ALTER “password” TYPE
ALTER “company” TYPE VARCHAR(255), ALTER “theme” TYPE VARCHAR(255);

It throws this error:

ERROR: relation “UQE_user_login” already exists

This was found to be a bug in PostgreSQL and a patch is in the works that, at the latest, should be included in the next minor release scheduled for August. The mailing list discussion on the issue can be found here

In the mean time, though, I find it curious that the initial setup of Grafana is having to run ALTER TABLE statements on a table that was just created. Couldn’t it define the data types properly at table creation?

1 Like

I have the same problem see my post Ubuntu 18.04 install problem

What can I do to have a supported PostgreSQL version e.g. 11.3 (since only the most recent minor versions are available)?

I’m not 100% sure on that. You could try asking on the debian package maintainers list (see below). I think there’s a way you can pin the minor version that you want using apt and then it will grab that from the repo if it is available
Sign up to send to the mailing lists here -

Why even use VARCHAR at all ? Just use text in postgres and this is a non-issue.


Do you already have a (suitable) solution for the problem?


There is a patch for PostgreSQL in the works as I linked to in my original post. However, it doesn’t appear that it’s going to cause another emergency release before August at this point (the next scheduled minor release date). Especially since the 11.4 release this bug came out in was itself an emergency release.

The only active solution at this point is to install 11.3 (or whichever major version’s release you need just prior to the latest minor). You can try and achieve this in APT based distros using version pinning as I stated above

I have an example with PostgreSQL in a presentation I did. Just adjust the wildcard for the version appropriately -

The other solution that Grafana could possibly do is to adjust their table generation code to not have to redefine the column definitions if the table is actually just being created during install. Not sure how easy that is, though, because just glancing through it appears they use some sort of ORM to generate the SQL.


I have tried just now with the version 11.3 and succeeded.But i want to know the proper version besides 11.3. i dont’ know “install 11.3 (or whichever major version’s release you need just prior to the latest minor)” means? How can i find the major versions besides 11.3? thx!

I meant the minor releases for the prior major versions of PostgreSQL (10, 9.6, 9.5, 9.4). This bug was introduced into all supported major versions of PostgreSQL, so if anyone is running a major version prior to 11, they will have to remain on the next to last minor release for each of them (10.8, 9.6.13, 9.5.17, 9.4.22).

I filed a Github issue for this as well, just in case people are looking for updates.

The latest minor release of PostgreSQL came out today (11.5, 10.10, 9.6.15, 9.5.19, 9.4.24) and contains a fix to the ALTER TABLE statement to allow the install of Grafana to proceed without errors anymore.

Updating to the latest minor release only requires a restart and installing the package on most systems will automatically do that for you (Debian/Ubuntu/RHEL/CentOS).