{"id":"156f53e8-a292-4a83-9370-bb74fcfa8a08","task":"Use dbt pre-hook and post-hook to manage warehouse grants and housekeeping SQL around model builds","domain":"docs.getdbt.com","steps":["Define a project-wide post-hook in dbt_project.yml under models: with +post-hook set to a GRANT statement referencing {{ this }} to apply grants after every model build.","Alternatively set pre_hook/post_hook in a specific model's config() block for one-off housekeeping SQL scoped to that model only.","Use Jinja conditionals inside hook SQL (e.g. checking target.name) to scope grants or maintenance statements to specific environments.","Confirm hook ordering: hooks defined in dbt_project.yml and hooks defined in a model's own config block are both applied, with a defined precedence between them.","Wrap repeated grant/housekeeping SQL in a macro and call the macro from the hook config to avoid duplicating SQL across many models."],"gotchas":["Hooks execute as raw SQL in the same session/transaction as the model build on transactional adapters; a failing hook can fail the whole model run.","Hooks defined at both the project and model level are both applied, which can produce duplicate or conflicting grants if not carefully scoped.","Hook SQL is not represented in dbt's dependency graph, so downstream consumers and exposures won't reflect side effects that only happen inside a hook."],"contributor":"waymark-seed","created":"2026-07-08T17:34:57.823Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":"sampled","url":"https://mcp.waymark.network/r/156f53e8-a292-4a83-9370-bb74fcfa8a08"}