Skip to content

Feat: Add destroy command to remove entire project resources #4328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

themisvaltinos
Copy link
Contributor

This update introduces the sqlmesh destroy command, which permanently deletes all engine-managed objects, including warehouse data, the associated state tables and cached SQLMesh assets, effectively resetting the entire project, fixes: #3684

Usage: sqlmesh destroy

This might be useful for cleaning up development projects, proof-of-concept work or pre-production phases with temporary setups.

⚠️ This is destructive and irreversible, and it removes both development and the production environment, so it should only be used when a full removal is necessary.

@themisvaltinos themisvaltinos requested review from erindru, treysp and a team May 7, 2025 15:41
@@ -1516,16 +1529,19 @@ def apply(
)

@python_api_analytics
def invalidate_environment(self, name: str, sync: bool = False) -> None:
def invalidate_environment(
self, name: str, sync: bool = False, protect_prod: t.Optional[bool] = True
Copy link
Member

@izeigerman izeigerman May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be in the public API of the context. If you want to reuse the method I suggest having a shared private method instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes good point actually only the invalidate method is used from it too so no need to call this

@@ -108,14 +108,15 @@ def update_environment_statements(
columns_to_types=self._environment_statements_columns_to_types,
)

def invalidate_environment(self, name: str) -> None:
def invalidate_environment(self, name: str, protect_prod: t.Optional[bool] = True) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto: why the new argument is optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right my bad no need for it

Copy link
Contributor

@georgesittas georgesittas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one question related to backup tables.

@@ -1523,6 +1536,7 @@ def invalidate_environment(self, name: str, sync: bool = False) -> None:
name: The name of the environment to invalidate.
sync: If True, the call blocks until the environment is deleted. Otherwise, the environment will
be deleted asynchronously by the janitor process.
protect_prod: If True, prevents invalidation of the production environment.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outdated comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add command to reset/remove entire project
3 participants