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
Built Distribution
Hashes for alembic-autogenerate-enums-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 467adc76f1ef32576e514ef55c400c28900547800b676dec349293519751c128 |
|
MD5 | a96a4afebfb43951f901c9a86b45d8c9 |
|
BLAKE2b-256 | 1533e395de48fcc4d9ac0b3c0d934d3eb128031da0888d2f32edd6a28d0a4c7c |
Hashes for alembic_autogenerate_enums-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07b8fa63b2fca107effc61d3dc86d7ff848dd73b0e6cc9c292e904edcaeb8278 |
|
MD5 | b6fcea45395ea6486086ce2bd2f87458 |
|
BLAKE2b-256 | e9115b63dac59e3761ca021359141ab0fab50e4cbca3ba6da90a7c7d2847328c |