Azoth CLI
Command-line interface for Azoth database operations.
Installation
Or build from source:
The binary will be available at target/release/azoth.
Usage
Options
-d, --db-path <DB_PATH>- Path to the database directory (default:./data)-v, --verbose- Enable verbose logging-h, --help- Print help-V, --version- Print version
Commands
Migration Management
List Migrations
List all registered migrations from a directory:
Show Migration History
Display all applied migrations with timestamps:
Show Pending Migrations
List migrations that haven't been applied yet:
Run Migrations
Apply all pending migrations:
Dry run (show what would be applied without executing):
Generate Migration
Create a new migration file:
This creates two files:
{version}_create_users_table.sql- Up migration{version}_create_users_table.down.sql- Down migration (rollback)
Rollback Migration
Rollback the last applied migration:
Skip confirmation prompt:
Database Status
View database information and projection status:
Example output:
Database Status
============================================================
Path: ./data
Schema Version: 3
Canonical Store:
Next Event ID: 1000
Projection Store:
Last Applied Event ID: 999
Schema Version: 3
✓ Projection is up to date
Run Projector
Apply pending events to projections:
Run continuously (processes events as they arrive):
Examples
Complete Migration Workflow
# Create a migrations directory
# Generate a new migration
# Edit the generated SQL files
# ... add your SQL to migrations/0002_create_users_table.sql ...
# Check what will be applied
# Apply migrations (dry run first)
# Apply for real
# View migration history
# Check database status
Database Operations
# Check database status
# Run projector once
# Run migrations with custom db path
# Enable verbose logging
Migration File Format
Migration files should be named: {version}_{name}.sql
Example: 0002_create_users_table.sql
-- Migration: create_users_table
-- Version: 2
-- Created: 2026-02-01 12:00:00 UTC
(
id INTEGER PRIMARY KEY,
username TEXT NOT NULL UNIQUE,
email TEXT NOT NULL UNIQUE,
created_at TEXT NOT NULL DEFAULT (datetime('now'))
);
(email);
Rollback file: 0002_create_users_table.down.sql
-- Rollback: create_users_table
-- Version: 2
IF EXISTS idx_users_email;
IF EXISTS users;
Exit Codes
0- Success1- Error (check error message for details)
Environment Variables
RUST_LOG- Controls logging level (e.g.,RUST_LOG=debug azoth status)
Tips
- Always test migrations in a development environment first
- Use dry-run mode to preview changes:
azoth migrate run --dry-run - Keep migrations in version control alongside your code
- Use descriptive migration names that explain what they do
- Test rollback migrations if you provide them
- Run projector after applying migrations:
azoth project - Check status regularly to monitor projection lag:
azoth status
Troubleshooting
"Failed to open database"
- Ensure the database path exists or can be created
- Check file permissions
- Verify the path is correct
"Migrations directory does not exist"
- Create the directory:
mkdir -p ./migrations - Or specify the correct path with
-m
"No pending migrations"
- All migrations have been applied
- Check
azoth migrate historyto see what's been applied - Generate new migrations if needed
"Projection lag: X events behind"
- Run
azoth projectto catch up - Use
azoth project --continuousfor real-time processing
Development
Build the CLI:
Run tests:
Run with cargo: