How do you track all tables and views created by dbt?

Viewed 664

We are using dbt in our project, and we found it's not easy to track "orphan" tables. These are tables or views created by dbt for which there is no matching current model.

These came about when a .sql file got renamed, or a view got converted to a table, etc...

Is there a way to find all of these orphan tables and views? Or at least a way to clear them out.

Ideas:

  • Use pre or post hooks to maintain a table in the database with all views/tables created by dbt
  • Schemas?

Note:

  • We are using MSSQL if it matters
1 Answers

Our team also used SQL Server and we have a macro we run as part of our CI for this. Here is the Pull Request, but we have yet to merge it, so you'll have to copy the macro yourself. The readme also has informatino on how to use it.

I'll update this answer once tsql-utils v0.8.0 is officially released!

Related