How to adapt segment / model / query etc to changed table name

Hello all

We have many complex queries and vizualisations built on models which in turn uses segments and metrics. However the underlying table names have changed. How can we adapt all of the SQL to this change without having to re-define each of the objects?

Thanks so much

If the table name was changed then you will need to reference it again in all objects mentioned above

Thanks so much @TonyC

Your recommendation is what I feared :hot_face:
When I attempt to change the table ie "Edit Query Defintion" for a Model, then I also loose all of the other definitions such as Selected Columns, Custom Column, Segment and other FIlters, etc. I was hoping I could simply edit the table name somewhere since everything remains the same other than the table's name.

You could use serialisation:

Which will dump your metabase instance definitions then you can do the changes on the yaml files and push the changes back to the instance with the new tables. But you will need a pro licence for that

Once again, thanks so much @TonyC

Would it be advisable to shut down the server, make a backup of the application database, and then edit the application database tables which contains all references to the previous table names?

That can be an option but is very tricky since you will need to edit a lot of places and it would be easy to corrupt something in between.

Some tables you definitely need to change in application database table are the metabase_table while Metabase is shutdown. Note that if you have any SQL questions - you would need to also manually change the query there (or in table report_card and report_card.dataset_query)

There are a lot of other places which has metadata since you are touching segment model and query ... So
I would say it is doable but it's gonna be hard.

1 Like