From 7794732d01a9eb2d1856d530501189f26c5083c2 Mon Sep 17 00:00:00 2001 From: Ishankoradia Date: Mon, 4 Mar 2024 19:28:53 +0530 Subject: [PATCH] delete model function --- dbt_automation/utils/dbtproject.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dbt_automation/utils/dbtproject.py b/dbt_automation/utils/dbtproject.py index 62d8169..3947440 100644 --- a/dbt_automation/utils/dbtproject.py +++ b/dbt_automation/utils/dbtproject.py @@ -69,3 +69,13 @@ def write_model_config(self, schema: str, models: list, **kwargs) -> None: ) return self.strip_project_dir(models_filename) + + def delete_model(self, model_relative_path: Path): + """Delete a model; relative path will look like models/intermediate/example_model.sql""" + + model_path = Path(self.project_dir) / model_relative_path + if model_path.exists(): + model_path.unlink() + return True + + return False