Skip to main content

sqb janitor

Identifies and removes stale warehouse relations that are no longer part of the project. Requires janitor.enabled = true in sqlbuild_project.toml.

Usage

sqb --project-dir <path> janitor [flags]

Flags

FlagDescription
--auto-approveSkip the confirmation prompt and delete immediately
--retention-daysOverride the configured retention period (days)

Configuration

Configure janitor behavior in sqlbuild_project.toml:
[janitor]
enabled = true
retention_days = 30
delete_tracked_only = true
exclude_patterns = ["audit_*", "tmp_*"]
See Project Configuration for details on janitor settings.

Examples

# Interactive mode (prompts for confirmation)
sqb janitor

# Auto-approve deletion
sqb janitor --auto-approve

# Override retention to 7 days
sqb janitor --retention-days 7

State history pruning

In addition to cleaning up stale relations, the janitor prunes old rows from _sqlbuild_fingerprints and _sqlbuild_source_freshness tables, retaining only the latest record per identity. This keeps state tables compact without affecting change detection.

Safety

Janitor prompts for confirmation before deleting. The confirmation requires typing an exact string to prevent accidental deletion. Use --auto-approve only in CI or when you’re certain.