Metadata-Version: 2.4
Name: migrator-cli
Version: 0.3.0
Summary: Universal migration CLI for Python apps
Project-URL: Homepage, https://github.com/Adelodunpeter25/migrator
Project-URL: Repository, https://github.com/Adelodunpeter25/migrator
Project-URL: Issues, https://github.com/Adelodunpeter25/migrator/issues
Project-URL: Changelog, https://github.com/Adelodunpeter25/migrator/blob/main/CHANGELOG.md
Author-email: Peter Adelodun <adelodunpeter24@gmail.com>
License: MIT
License-File: LICENSE
Keywords: alembic,cli,database,migration,orm,sqlalchemy
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Requires-Dist: alembic>=1.13.0
Requires-Dist: mako>=1.3.0
Requires-Dist: psycopg2-binary>=2.9.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: rich>=13.0.0
Requires-Dist: sqlalchemy>=2.0.0
Requires-Dist: typer>=0.9.0
Description-Content-Type: text/markdown

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

## 📦 Installation

```bash
# 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](MIGRATION_GUIDE.md) first.

### 1. Set up your database URL

Create a `.env` file:

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

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

### 2. Initialize migrations

```bash
migrator init
```

### 3. Create your first migration

```bash
migrator makemigrations "create user table"
```

### 4. Apply migrations

```bash
migrator migrate
```

## 📖 Commands

```bash
# 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
```

## 🏗️ Advanced Usage

### Nested Project Structures

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

### Async SQLAlchemy

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

### Custom Config

```bash
migrator init --config backend/settings.py
```

### Verbose Mode

```bash
migrator init --verbose
```

## 🔧 Troubleshooting

**Base not found?** Use `--base` flag:
```bash
migrator init --base app.core.database:Base
```

**Existing database?** Use `stamp`:
```bash
migrator stamp head
```

## 🤝 Contributing

Contributions welcome! Submit a Pull Request.

## 📄 License

MIT License - see [LICENSE](LICENSE) file.
