skillfed

alembic_utils

A sqlalchemy/alembic extension for migrating procedures and views

alembic-utils v0.8.8 1.6M downloads/30d#3,726 on PyPI300
Permissive license MIT AGING released

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-utils

uv

uv add alembic-utils

poetry

poetry add alembic-utils

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Programming Language :: SQL

Tags

alembic postgresql autogeneratedatabase migration functions viewssqlalchemy postgres schema migrationalembic materialized views triggerspostgresql function migration toolalembic extension postgres entitiesdatabase procedure migration
database-migrationpostgresqlsqlalchemy

More Database packages