Skip to main content

Alembic hook that allows enums values to be upgraded and downgraded in migrations automatically

Project description


This package implements an Alembic hook that causes alembic revision --autogenerate to output PostgreSQL ALTER TYPE .. ADD VALUE SQL statements as part of new migrations.


Add the line:

import alembic_autogenerate_enums

To the top of your


Since ALTER TYPE .. ADD VALUE cannot run transactionally, each op.sync_enum_values() call creates its own temporary private DB connection. See


We have incredibly basic tests in a sample project.

mkvirtualenv alembic-autogenerate

Install the main autogenerate package and then the test harness:

pip install -e .
pip install -e test-harness
createuser alembic-autogenerate
createdb -O alembic-autogenerate alembic-autogenerate_db
cd test-harness && pytest

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alembic-autogenerate-enums-0.1.2.tar.gz (4.9 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page