Skip to main content

Universal migration CLI for Python apps

Project description

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 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
  • Pythonic CLI — clean, readable, extensible commands

📦 Installation

# Quick install
curl -sSL https://raw.githubusercontent.com/Adelodunpeter25/migrator/main/install.sh | bash

# Or using pip
pip install migrator-cli

# Or using uv
uv add migrator-cli

🚀 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

Or use settings.py, config.py, config.yaml, or config.toml.

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"

# Apply migrations
migrator migrate

# 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

⚙️ Configuration

Migrator auto-detects your database URL from .env, environment variables, settings.py, config.py, config.yaml, or config.toml.

# .env file
DATABASE_URL=postgresql://user:password@localhost:5432/dbname

🔧 Troubleshooting

Existing database with tables?

migrator init
migrator makemigrations "initial"
migrator stamp head  # Don't run migrate!

See MIGRATION_GUIDE.md for detailed instructions.

Foreign key constraint errors?
Use migrator stamp head to mark existing database as migrated.

Missing database driver?
PostgreSQL: psycopg2-binary is included. For others: pip install pymysql (MySQL) or pip install cx_oracle (Oracle).

🤝 Contributing

Contributions welcome! Submit a Pull Request.

📄 License

MIT License - see LICENSE file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

migrator_cli-0.2.0.tar.gz (79.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

migrator_cli-0.2.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file migrator_cli-0.2.0.tar.gz.

File metadata

  • Download URL: migrator_cli-0.2.0.tar.gz
  • Upload date:
  • Size: 79.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for migrator_cli-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1ba76132488a3d6edeb674635e7a40da96f073d5c0917e946dd8ed44fee4af77
MD5 406b495dd133bb094a74573d26f07067
BLAKE2b-256 32a96d3b79686d90a8b9c36706ac6a638458c6910dc246e15875e7ff9e913fb1

See more details on using hashes here.

File details

Details for the file migrator_cli-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: migrator_cli-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for migrator_cli-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0808601a1cfb67486dc3a940d822a5855b9d71a9f640ac190044e8af319c7210
MD5 a23af6d70acb42f7dd359682ccb7541b
BLAKE2b-256 8738fa0cdaf66d85fb05a2c364d064689c86adb3d01599ad01fc978e3d6ff165

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page