mongodb-migrations
A database migration tool for MongoDB
What it is and what it does
mongodb-migrations is a command-line and programmatic tool for versioning and applying schema changes to MongoDB databases. It works by reading timestamped Python migration files from a migrations folder, each containing a Migration class with upgrade and downgrade methods, and tracking which migrations have been applied via a metastore collection in MongoDB itself.
The tool is designed for teams that need to evolve their MongoDB schema over time without losing data. It supports both CLI execution (via the `mongodb-migrate` command) and direct Python API calls through MigrationManager, allowing you to integrate migrations into deployment pipelines. Configuration is handled via config.ini or command-line arguments, supporting both direct host/port/database settings and MongoDB connection URLs with optional authentication.
Use it for:
- Apply coordinated schema changes across a MongoDB database as your application evolves, tracking which migrations have run.
- Downgrade to a previous migration state by running downgrade methods when a deployment needs to be rolled back.
- Migrate to a specific point in time using --to_datetime to upgrade or downgrade only to a particular migration timestamp.
- Integrate migrations into CI/CD pipelines by calling MigrationManager programmatically instead of using the CLI.
- Manage multiple MongoDB instances with the same migration set by configuring different databases in config.ini or command-line arguments.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Manages schema migrations for MongoDB databases by running timestamped Python migration files that define upgrade and downgrade operations against your data.
Yes, if you need MongoDB schema versioning and can accept a dormant project. The tool is stable for its core use case (running timestamped migrations), has no known vulnerabilities, and low install friction. However, the 823-day maintenance gap and GPLv3 copyleft license mean you should verify compatibility with your MongoDB and Python versions before adopting, and confirm that GPLv3 licensing aligns with your project's legal requirements.
Install
mongodb-migrations on PyPI
pip
pip install mongodb-migrationsuv
uv add mongodb-migrationspoetry
poetry add mongodb-migrationsInstalling mongodb-migrations
Before you install
Low friction install with only pymongo and configparser as runtime dependencies. Project is dormant (last commit 2024-08-05, no release for 823 days), so expect no active maintenance or bug fixes going forward.
License in practice
GPLv3 copyleft license means any code that uses this package must also be released under GPLv3 or a compatible license; proprietary projects cannot incorporate it without legal risk.
Quickstart
pip install mongodb-migrations
# Create migrations/20160320145400_description.py with a Migration class extending BaseMigration
# Implement upgrade() method
from mongodb_migrations.migration_manager import MigrationManager
manager = MigrationManager()
manager.config.config_file = "config.ini"
manager.config._from_ini()
manager.run()
Requires a config.ini file with MongoDB connection details (host/port/database or url) and a migrations folder with timestamped migration files.
Verify before relying
- Whether the dormant status and 823-day gap since last release pose compatibility risks with current MongoDB or Python versions.
- Whether GPLv3 copyleft applies to migration scripts themselves or only to the tool's source code.
Package facts
| License | GPLv3 (copyleft) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — pymongo, configparser |
| Maintenance | dormant — 823 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 107,848/month — #12,592 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mongodb_migrations-1.3.1-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
alembicAlembic generates and manages database schema…
permissive · top 1,000 on PyPI
yoyo-migrationsYoyo-migrations is a database schema migration…
permissive · top 15,000 on PyPI
Flask-PyMongoFlask-PyMongo integrates MongoDB database…
permissive · top 15,000 on PyPI
clickhouse-migrationsApplies versioned SQL migrations to ClickHouse…
permissive · top 15,000 on PyPI
peewee-migratePeewee Migrate provides a command-line and…
permissive · top 15,000 on PyPI
sqlalchemy-migrateProvides database schema migration management…
permissive · top 15,000 on PyPI
Flask-MigrateFlask-Migrate handles SQLAlchemy database…
permissive · top 5,000 on PyPI
django-pg-zero-downtime-migrationsProvides a Django database backend for…
permissive · top 15,000 on PyPI
schemachangeschemachange is a Python tool that manages…
permissive · top 15,000 on PyPI
maggmaMaggma provides a unified interface for…
unclear · top 15,000 on PyPI