<@U088WCP3B4P> create schema if not exists ANALYTI...
# ask-elementary-ai
d
@kapa.ai create schema if not exists ANALYTICS_DB_PRODUCTION.elementary I dont want it to create schema, let terraform do it
k
A message from kapa.ai
To prevent Elementary (via dbt) from creating the schema (e.g.,
ANALYTICS_DB_PRODUCTION.elementary
) and instead let Terraform handle schema creation, you have a couple of options: 1. Pre-create the schema with Terraform: As you mentioned, you want Terraform to manage schema creation. Simply ensure the schema exists before running any dbt/Elementary commands. If the schema already exists, dbt/Elementary will use it and not attempt to create it. 2. Elementary/DBT will not create the schema if it already exists: By default, dbt (and thus Elementary) will only attempt to create the schema if it does not exist. If Terraform has already created the schema, dbt will not try to create it again, so there will be no conflict or redundant creation attempt. This is confirmed in several support threads, where users are advised to manually create the schema if they do not want dbt/Elementary to do so automatically. For example, "As a workaround until we make the required changes, is it possible for you to create the schema ... manually with a user that does have permissions?" and "If the schema is already there, we don’t create it on the fly" [Slack thread](https://slack.com/archives/C02CTC89LAX/p1661125630123839). 3. No configuration to disable schema creation entirely: There is currently no documented configuration in Elementary or dbt to explicitly disable the schema creation logic. The best practice is to ensure the schema exists before running dbt/Elementary, which aligns with your Terraform approach. Summary: Let Terraform create the schema before running dbt/Elementary. As long as the schema exists, dbt/Elementary will not attempt to create it, and there is no need for further configuration. If you have a very specific use case (e.g., you want to prevent even the attempt to create the schema in all cases), you would need to modify dbt/Elementary macros, but this is not recommended or documented as a standard approach. If you need to customize the schema name or location, you can use the
+schema
or
+meta: schema_name
configuration in your
dbt_project.yml
as usual, but schema creation itself is handled as described above. Let me know if you need more details or have a specific scenario in mind!