CLI Tenant¶
The cli-tenant command provides unified tenant management across MongoDB and Neo4j databases. This is the recommended CLI for tenant operations as it ensures consistency across both databases.
Installation¶
The CLI tool is available after activating the Poetry shell in the backend directory:
Once in the Poetry shell, the cli-tenant command is available.
Usage¶
Environments¶
| Environment | Description |
|---|---|
dev |
Local development |
staging |
Staging environment |
production |
Production environment |
test |
Test environment |
Commands¶
| Command | Description |
|---|---|
test-connection |
Test connections to both MongoDB and Neo4j |
list-tenants |
List all tenants from both databases with comparison |
inspect-tenant |
Show comprehensive tenant info from both databases |
clear-tenant |
Remove tenant data from both databases |
copy-tenant |
Copy tenant data between environments |
compare-envs |
Compare tenant data between two environments |
most-recent-env |
Find which environment has the most recent data |
Command Reference¶
test-connection¶
Test connections to both MongoDB and Neo4j databases.
list-tenants¶
List all tenants from both databases with comparison.
| Option | Description |
|---|---|
--deep-check |
Perform deep LightRAG consistency analysis for each tenant |
Example with deep check:
inspect-tenant¶
Show comprehensive tenant information from both databases.
| Argument | Description |
|---|---|
tenant |
Tenant identifier (e.g., example_com) |
Example:
clear-tenant¶
Remove tenant data from both databases. Use with caution!
| Argument | Description |
|---|---|
tenant |
Tenant identifier (e.g., example_com) |
| Option | Description |
|---|---|
--confirm |
Skip confirmation prompt |
Examples:
# Clear with confirmation prompt
cli-tenant --env staging clear-tenant dummy_com
# Clear without confirmation
cli-tenant --env staging clear-tenant dummy_com --confirm
copy-tenant¶
Copy tenant data between environments. This command does not require --env as it specifies source and destination explicitly.
| Argument | Description |
|---|---|
tenant |
Tenant identifier (e.g., example_com) |
| Option | Required | Description |
|---|---|---|
--source-env |
Yes | Source environment to copy from |
--dest-env |
Yes | Destination environment to copy to |
--dry-run |
No | Preview copy operation without executing |
--confirm |
No | Skip confirmation prompt |
--no-delete-destination |
No | Do not delete existing destination data before copying |
Examples:
# Copy from staging to test
cli-tenant copy-tenant dummy_com --source-env staging --dest-env test
# Dry run to preview
cli-tenant copy-tenant dummy_com --source-env staging --dest-env test --dry-run
# Copy without confirmation
cli-tenant copy-tenant dummy_com --source-env staging --dest-env test --confirm
compare-envs¶
Compare tenant data between two environments. This command does not require --env.
| Argument | Description |
|---|---|
tenant |
Tenant identifier (e.g., example_com) |
| Option | Required | Description |
|---|---|---|
--source-env |
Yes | Source environment to compare from |
--target-env |
Yes | Target environment to compare to |
Example:
most-recent-env¶
Find which environment has the most recent data for a tenant. Checks all environments automatically. This command does not require --env.
| Argument | Description |
|---|---|
tenant |
Tenant identifier (e.g., example_com) |
Example:
Examples¶
# Test database connections
cli-tenant --env staging test-connection
# List all tenants
cli-tenant --env staging list-tenants
# List tenants with deep consistency checks
cli-tenant --env staging list-tenants --deep-check
# Inspect a specific tenant
cli-tenant --env staging inspect-tenant dummy_com
# Clear tenant data (with confirmation)
cli-tenant --env staging clear-tenant dummy_com
# Copy tenant from staging to test
cli-tenant copy-tenant dummy_com --source-env staging --dest-env test
# Compare tenant between environments
cli-tenant compare-envs dummy_com --source-env staging --target-env test
# Find most recent environment
cli-tenant most-recent-env dummy_com
Exit Codes¶
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Error |
130 |
Cancelled by user (Ctrl+C) |
Log Files¶
All operations are logged to a file. The log file path is displayed when running any command:
Related Documentation¶
- CLI Database (Advanced) - Low-level database-specific tools
- Backend Setup - Environment configuration