sqlfy CLI
Flyway SQL migration parser — schema graph engine, LLM vector chunk builder, and migration analysis toolkit.
Features
- Schema Analysis: Parse Flyway migrations, reconstruct schema state, detect anti-patterns
- Graph Visualization: Export schema as DOT, Mermaid, Excalidraw, Draw.io, interactive HTML
- Natural Language Q&A: RAG-powered schema assistant with Claude integration
- Migration Safety: Validate ordering, detect drift, analyze rollback feasibility, simulate changes
- Developer Tools: SQL linting, dependency analysis, column-level lineage tracking
Requirements
- Python 3.11+
- uv (recommended) or pip
Quick Start
Install uv (if not already installed)
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
Install sqlfy
# Clone the repo (if not already cloned)
git clone https://github.com/yourorg/sqlfy
cd sqlfy/cli
# Run the install script (installs globally)
./install.sh
# Verify installation
./verify.sh
# Or install manually
uv build
uv pip install dist/sqlfy-*.whl
Development Setup
# Sync dependencies (creates .venv automatically)
uv sync --all-extras --group dev
# Activate the virtual environment
source .venv/bin/activate # macOS/Linux
.venv\Scripts\activate # Windows
# Install in editable mode
uv pip install -e .
Running Tests
# All tests
uv run pytest -v
# Specific test file
uv run pytest tests/test_core.py -v
# With coverage
uv run pytest --cov=sqlfy --cov-report=term-missing
Building
# Build wheel and source distribution
uv build
# Output: dist/sqlfy-VERSION-py3-none-any.whl
# dist/sqlfy-VERSION.tar.gz
Usage
Basic Commands
# Dump schema state as JSON
sqlfy dump migrations/ --format json > schema.json
# Generate LLM vector chunks
sqlfy chunks migrations/ --format json > chunks.json
# Export as Mermaid diagram
sqlfy graph migrations/ --format mermaid > schema.mmd
# Analyze schema for issues
sqlfy insights migrations/
# Health report with score
sqlfy health migrations/
Schema Evolution
# Compare two schema versions
sqlfy diff migrations-v1/ migrations-v2/
# Simulate a change before applying
sqlfy simulate migrations/ --sql "ALTER TABLE users ADD (status VARCHAR2(20));" --diff
# Detect drift between environments
sqlfy drift migrations-prod/ migrations-dev/
# Analyze rollback feasibility
sqlfy rollback-analysis migrations/
Developer Tools
# Validate migration ordering
sqlfy validate migrations/ --fix-numbering
# Analyze dependencies
sqlfy deps migrations/ --critical-path
# Lint SQL files
sqlfy lint migrations/ --min-score 80
# Column-level lineage
sqlfy lineage APP.USERS.EMAIL
Natural Language Q&A
# Set API key
export ANTHROPIC_API_KEY="sk-..."
# Ask a question
sqlfy ask migrations/ "Which tables have no primary key?"
# Interactive chat
sqlfy chat migrations/
Configuration
pyproject.toml
The project is configured via pyproject.toml:
- Dependencies: Core runtime deps (sqlglot, networkx, sqllineage)
- Optional dependencies:
yaml(PyYAML),dev(pytest) - Entry point:
sqlfycommand →sqlfy.main:main
uv.lock
Lockfile for reproducible builds. Regenerate with:
uv sync --upgrade
Project Structure
cli/
├── src/sqlfy/ # Source code
│ ├── commands/ # CLI command handlers (modular)
│ ├── analysis/ # Schema analysis modules
│ ├── domain/ # Core data models
│ ├── output/ # Export and visualization
│ ├── core.py # Schema parsing engine
│ ├── reconstructor.py # Migration reconstruction
│ └── main.py # CLI entry point (302 lines)
├── tests/ # Test suite (655 tests)
├── pyproject.toml # Project metadata and dependencies
├── uv.lock # Lockfile (148KB, 28 packages)
└── README.md # This file
Testing
Tests use pytest with comprehensive coverage:
- 655 passing tests, 6 skipped
- Coverage: Core parsing, reconstruction, analysis, export, CLI commands
- Run time: ~2.5s
Add a new test
- Create
tests/test_myfeature.py - Import the module to test
- Write test functions starting with
test_ - Run:
uv run pytest tests/test_myfeature.py -v
Contributing
- Create a feature branch
- Make changes
- Add tests for new functionality
- Run
uv run pytest -vto verify - Build and test install:
uv build && uv pip install dist/sqlfy-*.whl - Submit PR
License
See LICENSE file in repository root.
Support
- Issues: GitHub Issues
- Docs: See main README in repository root
- Examples:
cli/examples/directory
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sqlfy_cli-0.50.2.tar.gz
(292.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
sqlfy_cli-0.50.2-py3-none-any.whl
(256.0 kB
view details)
File details
Details for the file sqlfy_cli-0.50.2.tar.gz.
File metadata
- Download URL: sqlfy_cli-0.50.2.tar.gz
- Upload date:
- Size: 292.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b22139b4d65b3ca2a0b498302849d4f88481a936c2b9d237e6c5510c5901bd74
|
|
| MD5 |
5dfe0d2480542d8d88497246481abb5e
|
|
| BLAKE2b-256 |
db853a9b56eed5d02a188fcc096225a4df76224ea9893593eaa57d6b4e9983f4
|
File details
Details for the file sqlfy_cli-0.50.2-py3-none-any.whl.
File metadata
- Download URL: sqlfy_cli-0.50.2-py3-none-any.whl
- Upload date:
- Size: 256.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91b742f17d01ba9afbbe8ac7f28d46b4d91dedde2dc51c34f7e84175dfb0d9bc
|
|
| MD5 |
08a2fb87a98fac4564097d3b48a2b292
|
|
| BLAKE2b-256 |
651f84d3571f7b14920433dd7ece1315d3d8f74c55c654fa79f64bc5d1b48ad1
|