dbt

Changing a dbt model materialization in production


In dbt, if a model was initially deployed as a view in production, and in the next version of your dbt project, your team decides to change it to a table, what is the proper way to deploy the project to avoid getting an error during dbt run?


Solution

  • I don't think there should be a problem. You can simply change the materialization from the view to the table, merge the changes into your production git brunch, and on the next dbt run dbt will create a table in your database so all dependent models will reference this table instead of a view.

    Keep in mind that view will still exist in your database, so if you want to keep it clean, you will need to manually drop it.

    Please clarify if you have any specific concern about changing the materialization.