Deployment credentials and custom schema name macro

I have added target name to a job with the value: “production”

And in the generate_schema_name macro I have this simple IF statement:

    {%- if target.name == 'production' -%}
        {{ custom_schema_name }}

But yet when I run the job, I prepends the value of schema from Deployment Credentials:
image

And yet we can’t leave the schema there empty. But from my understanding, the ANALYTICS is “default_schema” and “custom_schema_name” would be from my project config, which in this test is +schema: base.

I created a workaround by adding a replace in the macro

{{ custom_schema_name | replace("analytics_", "") }}

but I feel there could be an easier and cleaner way to do this, especially since this will require people to remember what to put in their deployment credentials, which asks for a human error sooner or later…

Can you confirm which schema name is actually being created?

Can you paste your entire generate_schema_name.sql?

Can you paste your entire project.yml?

Cheers

Without the REPLACE the model is created in schema “analytics_base”.

The rest of the macro is just as normal:

{% macro generate_schema_name(custom_schema_name, node) -%}

    {%- set default_schema = target.schema -%}

    {%- if target.name == 'production' -%}

        {{ custom_schema_name | replace("analytics_", "") }}

    {%- else -%}
        {{ default_schema }}_{{ custom_schema_name | trim }}
    {%- endif -%}

{%- endmacro %}

For project.yml I do have a schema entry:

image