# Clean your warehouse of old and deprecated models

**URL:** https://discourse.getdbt.com/t/clean-your-warehouse-of-old-and-deprecated-models/1547
**Category:** Show and Tell
**Created:** [August 20, 2020, 8:57pm UTC](https://discourse.getdbt.com/t/clean-your-warehouse-of-old-and-deprecated-models/1547 "2020-08-20T20:57:42Z")
**Posts on this page:** 1
**Showing post:** 12

<div class="post-metadata">

### Author: ![erin](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/erin/32/1617_2.png) [@erin](https://discourse.getdbt.com/u/erin)
#### Post date: [July 26, 2022, 6:16pm UTC](https://discourse.getdbt.com/t/clean-your-warehouse-of-old-and-deprecated-models/1547/12 "2022-07-26T18:16:05Z")

</div>

I created another macro that’s helpful for debugging this `drop_old_relations` macro. Prints the nodes (models, seeds, snapshots) in your DBT graph:

```auto
{% macro print_graph() %}

    {% if execute %}
        {% set query %}

            {%- for node in graph.nodes.values() | selectattr("resource_type", "equalto", "model") | list
                            + graph.nodes.values() | selectattr("resource_type", "equalto", "seed") | list
                            + graph.nodes.values() | selectattr("resource_type", "equalto", "snapshot") | list %}
                SELECT
                '{{node.config.schema}}' AS schema_name
                , '{{node.name}}' AS ref_name
                , '{{node.alias}}' AS alias
                , '{{node.resource_type}}' AS resource_type
                {% if not loop.last %} UNION ALL {% endif %}
            {%- endfor %}
        {% endset %}

        {%- set result = run_query(query) -%}
        {% if result %}
            {%- for node in result -%}
                {% do log(node, True) %}
            {%- endfor -%}
        {% endif %}
    {% endif %}

{% endmacro %}

```

Runnable with `dbt run-operation print_graph`

---

_[View the full topic](https://discourse.getdbt.com/t/clean-your-warehouse-of-old-and-deprecated-models/1547)._
