Hello,
I currently have a table, in one of my Postgres databases, that is used in 11 different cards
when I do :
select * from report_card left join metabase_table mt on report_card.table_id = mt.id
If I want these 11 cards to use another table with the exact same structure (same columns), what is the best/cleanest way to do the swap? I am trying to avoid doing it manually or recreating the cards.
(I suppose if a card is built from a question it would be possible to turn that question into a model and play with the model definition, but this situation is a card built directly from a table.)
In case the process might be different if I need to change the table with a model ( still same structure ) please let me know as well as it is what I'll be most likely doing.
Thanks for your help,
Hi @senseibara
Changing source requires more than just changing the table ID. There's also field IDs, so if you only changed the table, then the fields would still reference somewhere else.
Probably the easiest to just manually edit the 11 questions and re-create them based on the new table.
If you have many hundreds of questions, then creating a script would likely be easier.
Hi Flamber,
Thanks for the quick reply.
What would the script be doing then? Do you mean updating all the table & field ids?
@senseibara Yes. If you don't update all the IDs to match the expected tables/fields, then you are creating corruptions. You have 11 questions, just manually update them.
I have the same situation very often and it sometimes involves more than that. So good to have a script that can help with this task.
Thanks a lot for your help
Sorry, @flamber last question,
Does this apply to models too? I mean If I need to swap a table with a model. Unless I'm missing something, cards that are made using a model doesn't seem to have a table id or any id that could reference a model, do they?
@senseibara It's complicated. Try. Depending on how the Model is referencing metadata, then you could end up in the same problem.
We will create a tool to make this easier to hot swap: https://www.metabase.com/roadmap/
So nice to see this in the roadmap, it'd be life-changing!
Thanks again