Skip to main content

Database migration management tool with dependency graph analysis, phased execution, and batch tracking for yoyo-migrations

Project description

MigChain

Database migration management CLI tool built on top of yoyo-migrations.

Features:

  • Dependency graph analysis with cycle detection
  • Phased execution (schema + inserter migrations)
  • Batch tracking for --rollback-latest
  • Domain-based filtering (--include, --exclude)
  • Dry-run mode with JSON plan export
  • Mermaid dependency graph visualization

Installation

uv add migchain
# or
pip install migchain

Usage

# Apply pending migrations
migchain --dsn postgresql://user:pass@localhost/mydb --apply

# Use DATABASE_URL env var
export DATABASE_URL=postgresql://user:pass@localhost/mydb
migchain --apply

# Rollback latest batch
migchain --rollback-latest

# Dry run with verbose output
migchain --dry-run -vv

# Filter by domain
migchain --include auth,billing --apply

# Export dependency graph
migchain --show-graph --graph-out deps.mmd

# Custom migrations directory
migchain --migrations-dir ./db/migrations --apply

Configuration

Flag Env Var Description
--dsn DATABASE_URL PostgreSQL connection string
--migrations-dir Path to migrations root (default: ./migrations)
--apply Apply pending migrations (default)
--rollback Rollback all applied migrations
--rollback-one Rollback one safe leaf migration
--rollback-latest Rollback latest applied batch
--reload Full reload: rollback all, then apply all
--dry-run Show plan without executing
--no-inserters Skip inserter migrations
--include Comma-separated domains to include
--exclude Comma-separated domains to exclude
-v / -vv Increase verbosity
--show-graph Print Mermaid dependency graph
--graph-out Write graph to file
--json-plan-out Export execution plan as JSON

License

MIT

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

migchain-2.0.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

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

migchain-2.0.0-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file migchain-2.0.0.tar.gz.

File metadata

  • Download URL: migchain-2.0.0.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for migchain-2.0.0.tar.gz
Algorithm Hash digest
SHA256 afc1c18d5e4601300775fb7c44e1b4fe2eede4c156d45056a11c455a0e91ccaa
MD5 349cc9f9722339495b26cfe95760eb46
BLAKE2b-256 e9211bc373b2b01583467e02f8efc12a2b69489826e3baa7f46e432a83f0145d

See more details on using hashes here.

File details

Details for the file migchain-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: migchain-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for migchain-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 448d97489846f44e2729d45a1ce3f686e9f5f89c658dcbe91e520de2eb521308
MD5 14afbc0da84dcd8238fd7bce758ec73b
BLAKE2b-256 bff13e98fe206e6bedb831d6f1a3a529b4c869bda5215f7c0689f74c61aefc00

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