alembic_utils
A sqlalchemy/alembic extension for migrating procedures and views
What it is and what it does
Alembic Utils is an extension to Alembic, the standard SQLAlchemy migration tool, that adds autogeneration support for PostgreSQL-specific database objects. While Alembic natively detects changes to SQLAlchemy models and generates migration scripts, it does not handle PostgreSQL functions, views, materialized views, triggers, or policies. This package fills that gap by letting you register these entities in your migration environment and have Alembic automatically detect when they are created, modified, or removed, then populate the upgrade and downgrade sections of your migration scripts.
You define PostgreSQL entities using classes like PGFunction, PGView, and PGTrigger, register them with the migration system, and then run `alembic revision --autogenerate` as usual. The tool compares your registered definitions against the database and generates the necessary SQL to bring them into sync. This eliminates manual SQL writing for these common schema changes and keeps your migrations declarative and version-controlled alongside your application code.
Use it for:
- Autogenerate migrations when adding or updating PostgreSQL stored functions in a SQLAlchemy project.
- Track changes to database views and materialized views as part of your standard Alembic workflow.
- Manage PostgreSQL row-level security policies alongside table schema migrations.
- Detect and migrate trigger definitions without writing raw SQL in migration scripts.
- Keep PostgreSQL procedures in sync with application code in a version-controlled migration history.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Extends Alembic to autogenerate database migrations for PostgreSQL functions, views, materialized views, triggers, and policies alongside standard SQLAlchemy model changes.
Yes, if you use Alembic with PostgreSQL and need to version-control functions, views, triggers, or policies. The low install friction, permissive license, and stable maintenance history make it a safe addition to SQLAlchemy projects. The aging release cycle is not a blocker—the package is feature-complete for its scope and the repository shows recent activity. Install it if PostgreSQL-specific schema objects are part of your migration strategy.
Install
alembic-utils on PyPI
pip
pip install alembic-utilsuv
uv add alembic-utilspoetry
poetry add alembic-utilsInstalling alembic_utils
Before you install
Low install friction with a pure-Python wheel. Maintenance status is aging—last release 491 days ago—but the repository remains active with recent commits and no archived status, suggesting the package is stable rather than abandoned.
License in practice
MIT license is permissive; you can use, modify, and distribute this package with minimal restrictions, making it suitable for both open-source and commercial projects.
Quickstart
pip install alembic_utils
# In migrations/env.py:
from alembic_utils.pg_function import PGFunction
from alembic_utils.replaceable_entity import register_entities
to_upper = PGFunction(
schema='public',
signature='to_upper(some_text text)',
definition='RETURNS text as $$ SELECT upper(some_text) $$ language SQL;'
)
register_entities([to_upper])
# Then: alembic revision --autogenerate -m 'create to_upper'
Requires PostgreSQL database; only works with Alembic and SQLAlchemy projects.
Verify before relying
- Whether the 491-day gap since last release indicates active maintenance or dormancy despite recent commits.
- Performance characteristics when managing large numbers of PostgreSQL entities in a single migration.
- Compatibility with PostgreSQL versions beyond the current stable releases.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — alembic, flupy, parse, sqlalchemy, typing_extensions |
| Maintenance | aging — 491 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,604,291/month — #3,726 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: alembic_utils-0.8.8-py3-none-any.whl
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
alembicAlembic generates and manages database schema…
permissive · top 1,000 on PyPI
alembic-autogenerate-enumsExtends Alembic's autogenerate to detect and…
permissive · top 15,000 on PyPI
schemainspectInspects PostgreSQL database schemas to extract…
permissive · top 15,000 on PyPI
starrocksProvides a SQLAlchemy dialect and Alembic…
permissive · top 15,000 on PyPI
Flask-AlembicFlask-Alembic integrates Alembic database…
permissive · top 15,000 on PyPI
sqlalchemy-viewsAdds CreateView and DropView SQL constructs to…
permissive · top 15,000 on PyPI
pytest-alembicA pytest plugin that runs built-in and custom…
permissive · top 5,000 on PyPI
alembic-postgresql-enumExtends Alembic to automatically detect and…
permissive · top 5,000 on PyPI
django-pgviews-reduxAdds first-class PostgreSQL view support to…
unclear · top 15,000 on PyPI
Flask-MigrateFlask-Migrate handles SQLAlchemy database…
permissive · top 5,000 on PyPI