# How to run all models daily and run specific view models when there is a change in them only

**URL:** <https://discourse.getdbt.com/t/how-to-run-all-models-daily-and-run-specific-view-models-when-there-is-a-change-in-them-only/17141>\
**Category:** Help\
**Tags:** best-practice, snowflake, orchestration-and-deployment, dbt-cloud, macros\
**Created:** [November 27, 2024, 1:17pm UTC](https://discourse.getdbt.com/t/how-to-run-all-models-daily-and-run-specific-view-models-when-there-is-a-change-in-them-only/17141 "2024-11-27T13:17:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![snfacnt](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@snfacnt](https://discourse.getdbt.com/u/snfacnt)\
**Post date:** [November 27, 2024, 1:17pm UTC](https://discourse.getdbt.com/t/how-to-run-all-models-daily-and-run-specific-view-models-when-there-is-a-change-in-them-only/17141/1 "2024-11-27T13:17:12Z")

</div>

## The problem I’m having

We would like to use a deployment strategy, in dbt cloud, that builds all models which needs to be run daily, among them we have view models which needs to be run only if there is any change in the base model of the view.

## The context of why I’m trying to do this

We need run all models daily, among them we have view models which needs to be run only if there is any change in the base model for the view.

models : stage\_orders, int\_orders , agg\_orders , agg\_order\_views

deployment strategy to run all the stage\_orders, int\_orders , agg\_orders daily and run the agg\_order\_views only when there is any change in agg\_orders model definition.

## What I’ve already tried

I’ve looked at the documentation and tried using the dbt run --select state:modified+ but it is not working. Tried creating a macro , but so far i haven’t managed to get to the desired command statement.

Thanks,  
dbt user.

---

<div class="post-metadata">

**Author:** ![snfacnt](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@snfacnt](https://discourse.getdbt.com/u/snfacnt)\
**Post date:** [November 28, 2024, 2:36am UTC](https://discourse.getdbt.com/t/how-to-run-all-models-daily-and-run-specific-view-models-when-there-is-a-change-in-them-only/17141/2 "2024-11-28T02:36:38Z")

</div>

This is solved by having 2 jobs  
job1) dbt run --exclude agg\_order\_views ## this runs all the models except agg\_order\_views  
job2) dbt run --select:modified+ +agg\_order\_views --exclude ## this will run when there is change in agg\_order\_view table

job2 is dependent on job1 and run immediately after job1 completes.

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/a7a7ca1fe379aaf90952b0e13118a817babcd14f.png) [@system](https://discourse.getdbt.com/u/system)\
**Post date:** [December 5, 2024, 2:36am UTC](https://discourse.getdbt.com/t/how-to-run-all-models-daily-and-run-specific-view-models-when-there-is-a-change-in-them-only/17141/3 "2024-12-05T02:36:39Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
