Skip to main content

Migrator

The Universal Migration CLI for Python Apps

A lightweight, framework-agnostic database migration tool for Python projects using SQLAlchemy. Migrator automates what Alembic requires developers to set up manually — making migrations as simple as Django's makemigrations and migrate, but flexible enough for Python any project.

✨ Features

  • Zero boilerplate — one command to init and start migrating
  • Auto-detect models — finds SQLAlchemy Base classes automatically
  • Smart config — no need to manually edit alembic.ini or env.py
  • Framework agnostic — works with FastAPI, Flask, or standalone SQLAlchemy

📦 Installation

# SQLite / no extras needed
uv add migrator-cli

# PostgreSQL
uv add migrator-cli[postgres]

# MySQL
uv add migrator-cli[mysql]

# All database drivers
uv add migrator-cli[all]

Requires Python 3.11+.

🚀 Quick Start

Note: If you have an existing database with tables, see MIGRATION_GUIDE.md first.

1. Set up your database URL

Create a .env file:

DATABASE_URL=postgresql://user:password@localhost:5432/dbname

2. Initialize migrations

migrator init

3. Create your first migration

migrator makemigrations "create user table"

4. Apply migrations

migrator migrate

📖 Commands

# Initialize migration environment
migrator init

# Create new migration
migrator makemigrations "add email to users"

# Create migration and show SQL
migrator makemigrations "add email to users" --show-sql

# Apply migrations
migrator migrate

# Apply migrations without confirmation
migrator migrate --yes

# Preview migration SQL without applying
migrator migrate --dry-run

# Rollback migrations
migrator downgrade

# Show migration history
migrator history

# Show current revision
migrator current

# Mark database as migrated (for existing databases)
migrator stamp head

# Show migration status
migrator status

🏗️ Advanced Usage

Nested Project Structures

migrator init --base app.core.database:Base
migrator makemigrations "initial" --base app.core.database:Base

Async SQLAlchemy

# Your .env
DATABASE_URL=postgresql+asyncpg://user:pass@localhost/db
# Migrator auto-converts to: postgresql://user:pass@localhost/db

Custom Config

migrator init --config backend/settings.py

Verbose Mode

migrator init --verbose

🔧 Troubleshooting

Base not found? Use --base flag:

migrator init --base app.core.database:Base

Existing database? Use stamp:

migrator stamp head

🤝 Contributing

Contributions welcome! Submit a Pull Request.

📄 License

MIT License - see LICENSE file.

Metadata

Release files for migrator-cli 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for migrator-cli 0.5.0
File Size Uploaded
migrator_cli-0.5.0.tar.gz 91.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for migrator-cli 0.5.0
File Interpreter ABI Platform
migrator_cli-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 111.0 kB

Release files / migrator_cli-0.5.0.tar.gz

Download URL migrator_cli-0.5.0.tar.gz
Size 91.1 kB
Tags Source
SHA-256 checksum
How to use checksums
dc5b59cb52d9de76dab1c1f6d2a04d44c70b92cd46b00ea4ac7a7f9cf95aba70
BLAKE2b-256 checksum
How to use checksums
5965912b55c44acf03e9cc6eb5141681e044cf9c41a45d3001c86c31df7e9f9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.5

Release files / migrator_cli-0.5.0-py3-none-any.whl

Download URL migrator_cli-0.5.0-py3-none-any.whl
Size 19.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d6c426cf971d4fca8bd1e35f2d63904fd8f3ad2ed3e692146e810f85ed01893
BLAKE2b-256 checksum
How to use checksums
ce60fed2964802ff572814232a6207d0c3a5b257c4bbc0eda53fa4dd3aafbb57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.5

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page