sqlalchemy-migrate

raw JSON →
0.13.0 verified Mon Apr 27 auth: no python maintenance

Database schema migration tool for SQLAlchemy. Current version 0.13.0. Release cadence: sporadic, last release 2020.

pip install sqlalchemy-migrate
error ModuleNotFoundError: No module named 'sqlalchemy_migrate'
cause Incorrect import path. The package name on PyPI is 'sqlalchemy-migrate', but the module is 'migrate'.
fix
Run 'pip install sqlalchemy-migrate' and use 'from migrate import ...'.
error ImportError: No module named migrate.versioning
cause The 'migrate' package is installed but missing 'versioning' submodule, possibly due to an outdated version or broken installation.
fix
Reinstall with 'pip install --upgrade sqlalchemy-migrate' or check that the package is not partially installed.
deprecated sqlalchemy-migrate is in maintenance mode. Consider using Alembic for new projects.
fix Use Alembic (pip install alembic) as it is actively maintained and more flexible.
gotcha The package is installed as 'migrate', but the import is 'from migrate import ...'. Users often try 'import sqlalchemy_migrate' which fails.
fix Use 'from migrate import versioning.api' and ensure the package is installed correctly.

Basic usage: create a repository and run migrations.

from migrate.versioning import api
from migrate.versioning.repository import Repository
import os

db_url = os.environ.get('DATABASE_URL', 'sqlite:///test.db')
repo_path = '/path/to/migrations'
# Create repository: api.create(repo_path, 'myapp')
# Upgrade: api.upgrade(db_url, repo_path, version=None)
print('Migration setup ready.')