I think there is a much better solution, which is also used by dbt_artifacts.
It consists of writing an incremental model like so:
{{ config(materialized="incremental") }}
SELECT
null::int AS id,
null::string AS name
WHERE 0=1
This allows the model to be build multiple times. The initial run (or when --full-refresh
is provided), it will be created empty. Subsequent runs, the query will result in 0 rows which will be appended, i.e. nothing is done. It will keep the data intact which you add by other means (macro’s or external inserts etc.)
dbt_artifacts uses this approach to. It allows the separation of the model design (model) and the model content (macros in their case). It also allows for proper referencing and unit testing if desired.