alembic-git-revisions
raw JSON → 6 verified Fri May 01 auth: no python
Alembic extension that automatically chains migration revisions based on git commit history, replacing manual dependency specification. Current version 6, requires Python >=3.11. Release cadence is irregular.
pip install alembic-git-revisions Common errors
error ImportError: cannot import name 'GitRevisionPlugin' ↓
cause Incorrect import path; package renamed or not installed.
fix
Run
pip install alembic-git-revisions and use from alembic_git_revisions import GitRevisionPlugin. error alembic.util.exc.CommandError: Can't locate revision identified by 'abc123' ↓
cause Missing git history or head revision not in sync with branches.
fix
Ensure you are on a branch with the expected commit history. Run
git log to verify. error TypeError: setup() missing 1 required positional argument: 'config' ↓
cause Calling setup without passing Alembic Config object.
fix
Create an alembic.config.Config instance and pass it:
plugin.setup(config). Warnings
deprecated Using standard `alembic revision --autogenerate` without GitAlembicCommand may cause broken revision chains. ↓
fix Always use the provided `GitAlembicCommand` subclass or invoke via the plugin's command wrapper.
gotcha The plugin requires a clean git working tree (no uncommitted changes) to generate revision dependencies. ↓
fix Commit or stash changes before running migration commands.
breaking Version 6 drops support for Python <3.11. Older Python versions will fail to install. ↓
fix Upgrade to Python 3.11+.
Imports
- GitRevisionPlugin wrong
from alembic_git_revisions.plugin import GitRevisionPlugincorrectfrom alembic_git_revisions import GitRevisionPlugin - GitAlembicCommand wrong
alembic.commandcorrectfrom alembic_git_revisions import GitAlembicCommand
Quickstart
from alembic.config import Config
from alembic_git_revisions import GitRevisionPlugin
import os
config = Config()
config.set_main_option('script_location', 'migrations')
git_plugin = GitRevisionPlugin()
git_plugin.setup(config)
print('Alembic git revisions plugin initialized.')