Skip to main content

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

Project description

alembic-autogenerate-enums

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.

Usage

Add the line:

import alembic_autogenerate_enums

To the top of your env.py.

Notes

Since ALTER TYPE .. ADD VALUE cannot run transactionally, each op.sync_enum_values() call creates its own temporary private DB connection. See https://bitbucket.org/zzzeek/alembic/issues/123/a-way-to-run-non-transactional-ddl

Tests

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.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file alembic-autogenerate-enums-0.1.1.tar.gz.

File metadata

File hashes

Hashes for alembic-autogenerate-enums-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cafd20643181268b98ea22d76cd159325154191e6de865caa5fe99536401e2e2
MD5 4bb9a9f220b4c999d33758281b8274df
BLAKE2b-256 6d2f502bb869c4d59b4338ed0cee1e3ce5e9aa6999df0af3e00db02f600c3552

See more details on using hashes here.

File details

Details for the file alembic_autogenerate_enums-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for alembic_autogenerate_enums-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 39b1b9ef8e2a970d43ce9fd73b6bb28d336fe704d9058f51cc59bd68944313c5
MD5 1d0ba2e3afc4e673e12a7b07a748ae03
BLAKE2b-256 ce602c79834a896a99b9abf7923ed8f9184da43ab8e02ff455c207744197c307

See more details on using hashes here.

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