Migration failed when updating from 6.0.2 to 6.1.0


After updating from 6.0.2 to 6.1.0 I am getting the following log entries when trying to start grafana:

t=2019-04-09T18:33:23+0200 lvl=info msg="Executing migration" logger=migrator id="Rename table user to user_v1 - v1"
t=2019-04-09T18:33:23+0200 lvl=eror msg="Executing migration failed" logger=migrator id="Rename table user to user_v1 - v1" error="pq: relation \"user_v1\" already exists"
t=2019-04-09T18:33:23+0200 lvl=eror msg="Exec failed" logger=migrator error="pq: relation \"user_v1\" already exists" sql="ALTER TABLE \"user\" RENAME TO \"user_v1\""
t=2019-04-09T18:33:23+0200 lvl=eror msg="Server shutdown" logger=server reason="Service init failed: Migration failed err: pq: relation \"user_v1\" already exists"

Do you know what could be causing this?



that is strange, we have no other reports like it . Try adding Rename table user to user_v1 - v1 to migration log table manually to flag it as executed

Thanks for the reply. It looks like that row in the migration_log table is already there:

select * from migration_log;

    id           | 7
    migration_id | Rename table user to user_v1 - v1

But it still doesn’t work. Do you have any other suggestions perhaps?

Just wondering, has “org_id” been changed to “account_id”? Just a guess. I don’t see any references to “account_id” in version 6.0.2.

1 Like

Just to add some more context here, using a k8s deployment and running a similar upgrade I ran into the same error.
In testing, I was able to reproduce the error in a vanilla deployment by changing the org name from “Main Org.” to “Something Else” and then restarting the services.

On startup, the same errors are logged.

Additionally, I didn’t see any ini options to set this value.

@tobbe666 are you deploying in a similar way, using k8s and updating something like the org name?

@torkel if i wanted to manually change the org name/id back to default, where would I look to do that?
So far i’ve been unable to find where that’s mapped.
Any help here is appreciated - my deployment is perfectly fine and I can restore easily enough, but I’d imagine some others might have some data/settings that’s not ephemeral.

seems like the issue is partly from here?

i just tried to reproduce this using mysql, but the migration code worked fine

I run it on a normal server. Also exported the postgres and tried to run it locally on my laptop but ran into the same problem. I haven’t touched the Org name.


Seems happen only with postgres backend.
Still working on to fix this issue:

drop table "user";
alter table user_v1 rename TO "user";
alter table "user" rename COLUMN org_id to account_id;

DROP INDEX grafana."IDX_dashboard_org_id";
DROP INDEX grafana."IDX_dashboard_provisioning_dashboard_id";
DROP INDEX grafana."IDX_dashboard_account_id";
DROP INDEX grafana."IDX_dashboard_gnet_id";
DROP INDEX grafana."IDX_dashboard_org_id_plugin_id";
DROP INDEX grafana."UQE_dashboard_account_id_slug";
DROP INDEX grafana."UQE_dashboard_org_id_folder_id_title";
DROP INDEX grafana."UQE_dashboard_org_id_uid";
alter table dashboard rename COLUMN org_id to account_id;
DROP TABLE dashboard_provisioning_tmp_qwerty;
DROP INDEX grafana."IDX_dashboard_provisioning_dashboard_id_name";
DROP INDEX grafana."IDX_data_source_org_id";
ALTER TABLE data_source rename COLUMN org_id to account_id;
DROP INDEX grafana."IDX_data_source_org_id";
DROP INDEX grafana."UQE_data_source_org_id_name";
DROP INDEX grafana."IDX_data_source_account_id";
ALTER TABLE api_key rename COLUMN org_id to account_id;
DROP INDEX grafana."IDX_api_key_org_id";
DROP INDEX grafana."UQE_api_key_org_id_name";
alter table plugin_setting drop column plugin_version;
alter table alert_notification drop column is_default;
alter table alert_notification drop column frequency;
alter table alert_notification drop column send_reminder;
alter table alert_notification drop column disable_resolve_message;
alter table alert drop column "for";
alter table alert_notification drop column "uid";

Seems happen here: Grafana not starting after upgrading from 6.0.2 to 6.1.3 : trying to insert a non existing column

@yverry - Did you find a workaround to this problem yet?

Today no, I’ve rollbacked the grafana version and backup database and watch each release note to see if a fix appear. A github issue is now open https://github.com/grafana/grafana/issues/16720

OK, thank you for your reply.


Upgrade to the latest 6.x first

1 Like

Agree with @yverry, please try to upgrade to v6.7.4 first.