Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom databases #38

Open
davidwitk opened this issue Jun 7, 2024 · 0 comments
Open

Support custom databases #38

davidwitk opened this issue Jun 7, 2024 · 0 comments

Comments

@davidwitk
Copy link

Custom schemas are supported, but not custom databases (only partially with the prod_database_replace feature).

In our project, we write and read to and from different databases. This setup is currently not possible with upstream_prod (a model fails when it selects models from different databases).

We've added support for this by copying the solution for custom schemas.

  1. Adding the macro get_custom_database.sql:
{% macro generate_database_name(custom_database_name=none, node=none, is_upstream_prod=False) -%}

    {%- set default_database = target.database -%}

    {%- if (target.name in ('prod') or is_upstream_prod == true) and custom_database_name is not none -%}

        {{ custom_database_name | trim }}

    {%- else -%}

        {{ default_database }}

    {%- endif -%}

{%- endmacro %}
  1. Adding this to the upstream_prod.ref macro:
{% set custom_database_name = parent_node.config.database %}
{% set parent_database = generate_database_name(custom_database_name, parent_node, True) | trim %}

It would be cool if upstream_prod supports this out-of-the-box 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant