88from sqlmesh .utils .date import yesterday_ds
99from sqlmesh .utils .errors import SQLMeshError
1010
11+ from sqlmesh .core .config .common import DBT_PROJECT_FILENAME
1112from sqlmesh .core .config .connection import (
1213 CONNECTION_CONFIG_TO_TYPE ,
1314 DIALECT_TO_TYPE ,
@@ -113,11 +114,10 @@ def _gen_config(
113114 - ambiguousorinvalidcolumn
114115 - invalidselectstarexpansion
115116""" ,
116- ProjectTemplate .DBT : """from pathlib import Path
117-
118- from sqlmesh.dbt.loader import sqlmesh_config
119-
120- config = sqlmesh_config(Path(__file__).parent)
117+ ProjectTemplate .DBT : f"""# --- Model Defaults ---
118+ # https://sqlmesh.readthedocs.io/en/stable/reference/model_configuration/#model-defaults
119+ model_defaults:
120+ start: { start or yesterday_ds ()}
121121""" ,
122122 }
123123
@@ -285,8 +285,13 @@ def init_example_project(
285285 cli_mode : InitCliMode = InitCliMode .DEFAULT ,
286286) -> Path :
287287 root_path = Path (path )
288- config_extension = "py" if template == ProjectTemplate .DBT else "yaml"
289- config_path = root_path / f"config.{ config_extension } "
288+
289+ config_path = root_path / "config.yaml"
290+ if template == ProjectTemplate .DBT :
291+ # name the config file `sqlmesh.yaml` to make it clear that within the context of all
292+ # the existing yaml files DBT project, this one specifically relates to configuring the sqlmesh engine
293+ config_path = root_path / "sqlmesh.yaml"
294+
290295 audits_path = root_path / "audits"
291296 macros_path = root_path / "macros"
292297 models_path = root_path / "models"
@@ -298,7 +303,7 @@ def init_example_project(
298303 f"Found an existing config file '{ config_path } '.\n \n Please change to another directory or remove the existing file."
299304 )
300305
301- if template == ProjectTemplate .DBT and not Path (root_path , "dbt_project.yml" ).exists ():
306+ if template == ProjectTemplate .DBT and not Path (root_path , DBT_PROJECT_FILENAME ).exists ():
302307 raise SQLMeshError (
303308 "Required dbt project file 'dbt_project.yml' not found in the current directory.\n \n Please add it or change directories before running `sqlmesh init` to set up your project."
304309 )
0 commit comments