diff --git a/macros/dbt_utils/schema_cleanup/drop_old_relations.sql b/macros/dbt_utils/schema_cleanup/drop_old_relations.sql index 2f0af53..8b55950 100644 --- a/macros/dbt_utils/schema_cleanup/drop_old_relations.sql +++ b/macros/dbt_utils/schema_cleanup/drop_old_relations.sql @@ -24,7 +24,7 @@ table_schema like '{{ target.schema }}%' and table_name not in ( {%- for model in current_models -%} - '{{ model.upper() }}' + '{{ model }}' {%- if not loop.last -%} , {% endif %} @@ -35,7 +35,6 @@ from models_to_drop where - -- intentionally exclude unhandled table_types, including 'external table` CONCAT( 'drop ' , relation_type , ' ' , relation_name , ';' ) is not null {% endset %} diff --git a/macros/dbt_utils/schema_cleanup/drop_schemas_by_prefixes.sql b/macros/dbt_utils/schema_cleanup/drop_schemas_by_prefixes.sql index efc124d..e8739b7 100644 --- a/macros/dbt_utils/schema_cleanup/drop_schemas_by_prefixes.sql +++ b/macros/dbt_utils/schema_cleanup/drop_schemas_by_prefixes.sql @@ -6,9 +6,9 @@ {# Fetch all schemas that use the current prefix #} {% do log('Fetching schemas for ' + prefix + '...', info=True) %} {% set schemas_table %} - select name - from sys.schemas - where name LIKE '{{prefix}}%' + select schema_name + from "{{ target.database }}"."information_schema"."schemata" + where schema_name LIKE '{{prefix}}%' {% endset %} {% set schema_names = run_query(schemas_table).columns[0].values() %}