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
File details
Details for the file alembic-autogenerate-enums-0.1.1.tar.gz
.
File metadata
- Download URL: alembic-autogenerate-enums-0.1.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.10.4 Darwin/22.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cafd20643181268b98ea22d76cd159325154191e6de865caa5fe99536401e2e2 |
|
MD5 | 4bb9a9f220b4c999d33758281b8274df |
|
BLAKE2b-256 | 6d2f502bb869c4d59b4338ed0cee1e3ce5e9aa6999df0af3e00db02f600c3552 |
File details
Details for the file alembic_autogenerate_enums-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: alembic_autogenerate_enums-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.10.4 Darwin/22.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39b1b9ef8e2a970d43ce9fd73b6bb28d336fe704d9058f51cc59bd68944313c5 |
|
MD5 | 1d0ba2e3afc4e673e12a7b07a748ae03 |
|
BLAKE2b-256 | ce602c79834a896a99b9abf7923ed8f9184da43ab8e02ff455c207744197c307 |