Skip to content

CLI Database (Advanced)

This page covers the low-level database-specific CLI tools: cli-mongo and cli-neo4j. These are advanced tools for database-specific maintenance tasks.

Use cli-tenant Instead

For most tenant operations, use cli-tenant which provides unified management across both MongoDB and Neo4j with consistency guarantees.

Installation

Both CLI tools are available after activating the Poetry shell in the backend directory:

cd backend
poetry shell

cli-mongo

MongoDB-specific operations for the vector storage layer.

Usage

cli-mongo --env <environment> <command> [OPTIONS]

Available Commands

Run cli-mongo --help to see all available commands:

Command Description
test-connection Test MongoDB connection
test-envs Test connections to all environments
list-tenants List all tenant data
inspect-tenant Inspect data for specific tenant
clear-tenant Clear all data for tenant
clear-orphaned Clear orphaned documents with missing tenant IDs
consistency-check Check database consistency for LightRAG data
sanitize-name Show sanitized tenant name for company
copy-tenant Copy tenant data between environments

Example

# Test MongoDB connection
cli-mongo --env staging test-connection

# Check consistency
cli-mongo --env staging consistency-check

cli-neo4j

Neo4j-specific operations for the knowledge graph layer.

Usage

cli-neo4j --env <environment> <command> [OPTIONS]

Available Commands

Run cli-neo4j --help to see all available commands:

Command Description
test-connection Test Neo4j connection
test-envs Test connections to all environments
list-databases List all company databases
create-database Create database for company
ensure-database Ensure database exists for company
database-info Get information about a database
drop-database Drop a database
drop-company Drop database for company
sanitize-name Show sanitized database name for company
copy-company Copy company data between environments
most-recent-env Find which environment has the most recent data
compare-envs Compare data between two environments
verify-labels Verify label standardization logic

Example

# Test Neo4j connection
cli-neo4j --env staging test-connection

# List all databases
cli-neo4j --env staging list-databases

When to Use These Tools

Use cli-mongo or cli-neo4j directly when you need:

  • Database-specific diagnostics: Consistency checks, orphan cleanup
  • Low-level operations: Database creation/deletion, label verification
  • Debugging: When cli-tenant operations fail and you need to investigate

For all other tenant operations, prefer cli-tenant.