Merge Databases in Admin Menu

Hi Metabase Team,

We have two databases which connects to the exact same connection. We intend to merge them so there is one database only. However, each database has its own questions, and we want to retain those questions.

How to safely merge these two databases while retaining those questions?

Hi @vincentimo

That’s really tricky, since the way Metabase stores information about database structures (tables and columns) and questions (and filters).
If the questions are created as Native/SQL, then it’s a lot easier, but otherwise I would recommend using the /reference (Browse Data > Learn about your data) section to find questions used by each table and manually re-create them.

It depends on how many questions and dashboards you have - if you have hundreds or thousands, then it might be worth trying to manually change the references in the application database (metadata).

We have... hundreds of questions for each database.

it might be worth trying to manually change the references in the application database (metadata)

By this, do you mean changing them directly in the Metabase DB? If so, is it sufficient to change all the foreign keys in metabase_table and report_card as shown in the attached diagram?

@vincentimo
Please remember to do a backup before, since manually changing the metadata can completely corrupt the data.
You’re missing metabase_field too.
And perhaps more (I don’t have access to my test setup, so doing this from memory).

But essentially you would just look at report_card and change all references from DB2 to DB1.

You also need to check report_card.dataset_query and report_card.visualization_settings (and …) for any references, such as parameters (aka filters).

Thank you for your suggestion, I’ll try that in the test environment first.