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.0.tar.gz
.
File metadata
- Download URL: alembic-autogenerate-enums-0.1.0.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 | 49a6fe1a9df48120cb2c4c9d2b8037c8e09799dbf684e339ccf7abd1a7efa966 |
|
MD5 | 891fd1bd8f87cf9c67eef744c9ff9d4f |
|
BLAKE2b-256 | f3bd60a62eb9f93c7a6673675c59cdd0ee5a5f2fe85ee3837d8ab1916eb718f4 |
File details
Details for the file alembic_autogenerate_enums-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: alembic_autogenerate_enums-0.1.0-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 | f2c5dfbfca81c8b3d08e7f17f0eabc5b2a9ad05d710f643586a4a05f53f80b5c |
|
MD5 | a6c5d2a14b945ce7559cdcac72fe97e9 |
|
BLAKE2b-256 | 24c29110d1491251463d640511da87167e07649d5127a7335d9fb3d5a723535e |