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

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for alembic-autogenerate-enums-0.1.0.tar.gz
Algorithm Hash digest
SHA256 49a6fe1a9df48120cb2c4c9d2b8037c8e09799dbf684e339ccf7abd1a7efa966
MD5 891fd1bd8f87cf9c67eef744c9ff9d4f
BLAKE2b-256 f3bd60a62eb9f93c7a6673675c59cdd0ee5a5f2fe85ee3837d8ab1916eb718f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for alembic_autogenerate_enums-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2c5dfbfca81c8b3d08e7f17f0eabc5b2a9ad05d710f643586a4a05f53f80b5c
MD5 a6c5d2a14b945ce7559cdcac72fe97e9
BLAKE2b-256 24c29110d1491251463d640511da87167e07649d5127a7335d9fb3d5a723535e

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