Context
I set up models based on a database dev
with id 1
, and created cards using these models.
When wanting to switch models to a database called prod
with id 2
, with a perfectly identical data scheme, cards returns this error Can not display has the referenced table comes from another database
After investigation using the API, what I discover is that when getting the informations about the model I get sth like this :
{
"dataset_query : {"database_id":2, "other_attr":"value"}
}
Therefore, the change from dev
to prod
was correctly done for the model.
However, when I check the indicator depending on this model, I get something like this :
{
"dataset_query : {"database_id":1, "other_attr":"value"}
}
What I understand from such observations is the following : When changing the database of a model, Metabase does not update the database_id of depending cards
Solution
- As the version 0.46 seems to have implemented the functionality of getting all cards linked to a model, it should also update the database of cards that depends on it.
- However, it raised the issue of cards that depends on multiple models. A good scenario would be to check if both models have the same database_id. If not, do nothing , and returns error when viewing the card.