-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
custom schemas #522
custom schemas #522
Conversation
@drewbanin this code looks great. I think this is OK to merge with the current naming conventions if you put three things in the docs:
in addition to generally documenting what the |
I love the approach here. What is the argument passed to the generate_schema_name? I had imagined this would work something like:
|
@cmcarthur I don't think we have access to |
@cmcarthur can you just give this a quick final pass? |
Specify custom schemas for models
TODO:
Usage
This branch uses a macro to generate model schema names, and users can override this macro to create alternative schema behavior.
This branch uses a macro called
generate_schema_name
to get a schema name for a model. By default, this macro just concatenates theschema
defined in the activeprofile
with theschema
defined in the model config, if any.To override this behavior, users can create a macro in their own project called
generate_schema_name
. In practice, this would look like:A more useful strategy uses the
profile
schema in development, and the custom model schema in production. The macro to do that looks like this:Since I think this will be a common strategy, I went ahead and added this to the global project too. So, to use the "default in dev, custom in prod" strategy, users should create
macros/generate_schema.sql
with these contents:Docs: https://dbt.readme.io/v0.9/docs/using-custom-schemas