Database schema compatibility between v6 and v7

We are looking at doing a partial migration from Grafana v6 to Grafana v7 – since some of the features and plugins we use are not really compatible with v7. Therefore we are planning to run v6 and v7 side by side. At the same time, we’d prefer to not “fork” the backend PostgreSQL database, but instead keep a single, consistent, datastore that both instances use. (I can go into the reasons here, but for example we’d like to keep a consistent user database)

What is the likelihood that this would work across major versions? I actually did a quick experiment, having both v6.2.2 and v7.1.1 instances using a single Postgres database, and things seemed to work just fine. The only breakage I noticed was when saving an edited dashboard in v7, the respective dashboard would no longer load in v6. That kind of behavior is actually acceptable, since the v6 instance and v7 instances would primarily be accessed by different sets of orgs.

I assume the official answer is “don’t do that, it will break things”, but I thought I’d check what the specific gotchas are, and whether anyone has wise words to share on the topic.

Hi Svet,

There have been a few changes to the database structure between v6.2.2 and v7.1.1 but nothing major. This will probably work but nothing that I can guarantee - we don’t explicitly support a shared database for multiple versions of Grafana.

The database migrations that we use to explicitly change the database schema can be seen here:

Did a quick scan and these are the migrations over the last 6 months:

  • An index added to the user table
  • the datasource table has an extra uid column (so should work ok for the older version of Grafana)
  • Annotations table got an index for the alert_id column
  • The alert table has a few additions - a changed column type (this might be a potential problem) and a new column for encrypted settings.

Which breaking change is stopping you from upgrading?

1 Like

Hi Daniel, thanks for the prompt and informative response! Apologies for the super-delayed one on my end.

Partly based on what you said, we actually went ahead and implemented the scenario I was describing. So far (~2 weeks later), it seems to be working nicely! We haven’t exactly pushed things to the limit (e.g. we don’t use alerting in Grafana), but I’d say your assessment that it should work appears to be right.

I did at one point review the migrations directory you linked to, but didn’t have a particularly easy time working out what’s what. So thank you for outlining the specific items to watch out for.

In terms of what’s stopping us from upgrading, it’s mostly plugin compatibility. For example in some of our orgs/dashboards, we use status panels quite heavily ( Although that plugin did actually recently get an update that fixes compatibility with Grafana v7, it still looks quite different in v7 (see below).

So while at this point it’s mostly cosmetic differences that are holding us back from upgrading across the board, part of it is just trying to not rock the boat too much for our users.

Example v6 look:

Example v7 look (also with custom font that we put in - though the main visual discrepancy is the lack of coloring of the panel border and header):