Upgrade PGSQL to version 15 and Grafana to 10.x

We are upgrading our Grafana environment from Grafana 9 to 10.
We also wanted to upgrade Postgresql to version 15 from 13.

I made a dump of the DB and removed version 13 and installed 15. Imported the data and restarted Grafana v9. This had no issue. Grafana started correctly and i could see the dashboards working fine.

But when i stooped Grafana and upgraded to the latest 10 version Grafana could not startup. We got the following error in the logging:

logger=migrator t=2023-12-21T14:27:39.916634545+01:00 level=info msg="Starting DB migrations"
logger=migrator t=2023-12-21T14:27:39.935661899+01:00 level=info msg="Executing migration" id="Add unique index team_org_id_uid"
logger=migrator t=2023-12-21T14:27:39.938332776+01:00 level=error msg="Executing migration failed" id="Add unique index team_org_id_uid" error="pq: permission denied for schema public" duration=2.669565ms
logger=migrator t=2023-12-21T14:27:39.938391592+01:00 level=error msg="Exec failed" error="pq: permission denied for schema public" sql="CREATE UNIQUE INDEX \"UQE_team_org_id_uid\" ON \"team\" (\"org_id\",\"uid\");"

When we roll back to version 9 Grafana started working correctly again.

  • What Grafana version and what operating system are you using?

  • What are you trying to achieve?

  • How are you trying to achieve it?

  • What happened?

  • What did you expect to happen?

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

  • Did you follow any online instructions? If so, what is the URL?

Hi @nahlizuvay,

Thanks for opening this post.

If I understand correctly, your Grafana backend is using PostgreSQL instead of the default SQLite?

Good day.

@usman.ahmad yes he is. Got the same problem here.

grafana_1   | logger=migrator t=2024-02-07T20:59:54.693510256+05:00 level=error msg="Executing migration failed" id="Add isPublic for dashboard" error="pq: column \"is_public\" of relation \"dashboard\" already exists" duration=2.686124ms
grafana_1   | logger=migrator t=2024-02-07T20:59:54.693548694+05:00 level=error msg="Exec failed" error="pq: column \"is_public\" of relation \"dashboard\" already exists" sql="alter table \"dashboard\" ADD COLUMN \"is_public\" BOOL NOT NULL DEFAULT false "
grafana_1   | Error: ✗ migration failed (id = Add isPublic for dashboard): pq: current transaction is aborted, commands ignored until end of transaction block

Grafana — latest, postgres 15.

Migration with clean db was great, but if you trying to startup grafana with existing BD and data is already there (restored dump from another installation for testing) you get errors above. Looks like troubles with migrations code.
Dont know how to fix this, didnt found any info. Asking for help. :frowning:

you have to deal with the above issue 1st. Any subsequent errors are just symptoms of the above error

Does the grafana server user defined in the ini file and the grafana server ip address have the needed permissions to the new database? or have you set the permissions to

souse@%