How to enable elementary only for some targets?
# ask-elementary-ai
o
How to enable elementary only for some targets?
k
A message from kapa.ai
To enable Elementary only for specific targets, you can add a configuration in your
dbt_project.yml
file that conditionally enables the Elementary package based on the target name. This is a common approach when you want to run Elementary in production environments but disable it in development environments to speed up local development. Here's how to do it:
Copy code
yaml models:   elementary:     +schema: "elementary"     +enabled: "{{ target.name in ['prod', 'analytics'] }}"
In this example, Elementary will only be enabled when your target name is either 'prod' or 'analytics'. You should replace these target names with the ones you actually use in your environment. This approach is recommended by Elementary's team and has been confirmed to work in multiple [Slack forum discussions](https://slack.com/archives/C02CTC89LAX/p1678208106811249). Alternatively, you can use a variable-based approach as shared by some community members:
Copy code
yaml models:   elementary:     +schema: "elementary"     +enabled: "{{ var('enable_elementary', target.name in ['prod', 'analytics']) }}"
With this configuration, Elementary will be enabled by default for the specified targets, but you can override it using the
--vars
flag in your dbt command:
Copy code
dbt run --vars '{"enable_elementary": false}'
This gives you more flexibility to enable or disable Elementary on a per-run basis, regardless of the target you're using.