CLI Commands
The qail command-line tool.
Installation
cargo install qail
Commands
qail init
Initialize a new QAIL project with interactive setup:
qail init
# đĒ QAIL Project Initialization
# Project name: my_app
# Select database mode:
# 1. PostgreSQL only
# 2. Qdrant only
# 3. Hybrid (PostgreSQL + Qdrant)
# ...
Generates qail.toml and necessary migration files.
qail parse
Parse QAIL text syntax to SQL:
qail parse "get users fields * where active = true"
# SELECT * FROM users WHERE active = true
qail pull
Extract schema from database:
qail pull postgres://user:pass@localhost/db > schema.qail
qail diff
Compare two schemas and show migration commands:
qail diff old.qail new.qail
qail check
Validate a schema file or preview migration safety:
# Validate schema
qail check schema.qail
# â Schema is valid
# Tables: 80
# Columns: 1110
# Indexes: 287
# â 82 primary key(s)
# Check migration safety
qail check old.qail:new.qail
# â Both schemas are valid
# Migration preview: 4 operation(s)
# â 3 safe operation(s)
# â ī¸ 1 reversible operation(s)
qail migrate up
Apply migrations:
qail migrate up old.qail:new.qail postgres://...
qail migrate down
Rollback migrations:
qail migrate down old.qail:new.qail postgres://...
qail migrate apply
Apply file-based migrations from migrations/ directory:
qail migrate apply
# â Found 1 migrations to apply
# â Connected to qail_test
# â 001_qail_queue.up.qail... â
# â All migrations applied successfully!
Reads qail.toml for database connection if not provided via --url.
qail migrate plan
Preview migration SQL without executing (dry-run):
qail migrate plan old.qail:new.qail
# đ Migration Plan (dry-run)
# ââ UP (2 operations) ââââââââââââââââââââââââââââââââââ
# â 1. ALTER TABLE users ADD COLUMN verified BOOLEAN
# â 2. CREATE INDEX idx_users_email ON users (email)
# âââââââââââââââââââââââââââââââââââââââââââââââââââââââ
# ââ DOWN (2 operations) ââââââââââââââââââââââââââââââââ
# â 1. ALTER TABLE users DROP COLUMN verified
# â 2. DROP INDEX IF EXISTS idx_users_email
# âââââââââââââââââââââââââââââââââââââââââââââââââââââââ
# Save to file
qail migrate plan old.qail:new.qail --output migration.sql
qail migrate analyze
Analyze codebase for breaking changes before migrating:
qail migrate analyze old.qail:new.qail --codebase ./src
# đ Migration Impact Analyzer
# Scanning codebase...
# Found 395 query references
#
# â ī¸ BREAKING CHANGES DETECTED
# ââ DROP TABLE promotions (6 references) ââââââââââââââ
# â â src/repository/promotion.rs:89 â INSERT INTO...
# â â src/repository/promotion.rs:264 â SELECT...
# ââââââââââââââââââââââââââââââââââââââââââââââââââââââ
qail watch
Watch schema file for changes and auto-generate migrations:
qail watch schema.qail
# đ QAIL Schema Watch Mode
# Watching: schema.qail
# Press Ctrl+C to stop
# [14:32:15] â Detected 2 change(s):
# ALTER TABLE users ADD COLUMN avatar_url TEXT
# With database connection
qail watch schema.qail --url postgres://... --auto-apply
qail lint
Check schema for best practices and potential issues:
qail lint schema.qail
# đ Schema Linter
# â 144 warning(s)
# âš 266 info(s)
#
# â users.customer_id Possible FK column without references()
# â Consider adding '.references("table", "id")' for referential integrity
#
# â orders Missing updated_at column
# â Add 'updated_at TIMESTAMPTZ not_null' for audit trail
# Strict mode (errors only, for CI)
qail lint schema.qail --strict
Lint Checks:
| Check | Level | Description |
|---|---|---|
| Missing primary key | đ´ ERROR | Every table needs a PK |
| Missing created_at/updated_at | â ī¸ WARNING | Audit trail columns |
_id column without references() | â ī¸ WARNING | FK integrity |
| Uppercase table names | â ī¸ WARNING | Use snake_case |
| SERIAL vs UUID | âšī¸ INFO | Consider UUID for distributed |
| Nullable without default | âšī¸ INFO | Consider default value |
qail sync generate
Generate trigger migrations from [[sync]] rules in qail.toml:
qail sync generate
# â Generating sync triggers...
# â Created migrations/002_qail_sync_triggers.up.qail
Used in Hybrid mode to automatically create PostgreSQL triggers that push changes to the _qail_queue table.
qail worker
Start the background worker to sync data from PostgreSQL to Qdrant:
qail worker --interval 1000 --batch 100
# đˇ QAIL Hybrid Worker v0.14.12
# đ Qdrant: Connected (localhost:6334)
# đ Postgres: Connected (5 connections)
#
# [2026-01-02 10:00:00] đ Syncing... (pending: 0)
Options:
--interval <ms>: Polling interval (default: 1000ms)--batch <size>: Batch size for sync (default: 100)
qail migrate status
View migration history for a database:
qail migrate status postgres://...
# đ Migration Status
# Database: mydb
# Migration table: _qail_migrations
# â Migration history table is ready
qail exec
Execute type-safe QAIL statements against a database:
# Inline QAIL execution
qail exec "get users fields id, email where active = true" --url postgres://...
qail exec "add users fields name, email values 'Alice', 'a@test.com'" --url postgres://... --tx
# From file
qail exec -f seed.qail --url postgres://...
# Dry-run (preview generated SQL)
qail exec "get users fields *" --dry-run
# đ Parsed 1 QAIL statement(s)
# đ DRY-RUN MODE - Generated SQL:
# Statement 1:
# SELECT * FROM users
# No changes made.
Options:
-f, --file <FILE>: Path to.qailfile with statements (one per line)-u, --url <URL>: Database connection URL--tx: Wrap all statements in a transaction--dry-run: Preview generated SQL without executing
Features:
- Type-safe execution via QAIL AST (
driver.execute(ast)) - Batch execution (multiple statements per file)
- Transaction support with automatic rollback on error
- Comments supported (
#and--)
qail fmt
Format QAIL text:
qail fmt "get users fields *" --indent
Options
| Flag | Description |
|---|---|
-d, --dialect | Target SQL dialect (pg, mysql) |
-f, --format | Output format (sql, ast, json) |
-v, --verbose | Verbose output |
--version | Show version |
--help | Show help |