Updating SQL view

Hello everyone!

First, thank you for this amazing tool, in our company everybody uses Metabase on a daily basis and we love it !

To better help non technical people search in our database, I’ve created multiple postgresql views. Some are pretty great but some others have been really poorly designed and should be rewritten. Since we can’t remove or update existing columns in a pgsql view, I’m wondering how I should proceed. Those views are used in many MB dashboard and I’m worried to break a lot of things so here are my questions :

  • Is there any danger to delete a view and create it again right after ? (assuming I recreate the same columns and name the view exactly as before). Will it affect the multiple questions and dashboards using this view ?

  • If I remove some columns which are used as foreign key in other tables, how will MB handle this ?

We’re using version 0.34

Thank you very much,

I’ve recreated views before and not had any problems. To be on the safe side, I used ALTER rather than DROP and CREATE, but that’s database dependent. If you’re being extra cautious turn off the database scanning in the admin settings.
2nd question - sorry, I don’t know. Try creating some test views.

Thanks for your reply !
I’ll wait for other answers if some of you have experienced this just to be sure. But as you said, I’ll create some test views and keep you posted after :slight_smile:

@scarbain If you have created questions based on one structure, but change that radically, then those questions will of course not work anymore and need to be updated. Metabase will not be able to guess what to change. I don’t think any tool is able to do that.

When you “update” a view, then make sure that you sync+scan the table right after. Either Admin > Databases > (db), or Admin > Data Model > (db) > (table) > top-right :gear:

Metabase should stop referencing the foreign keys, but I’m actually unsure how that’s handled. Give it a try and report back.