Skip to content
Advertisement

Altering an Enum field using Alembic

How can I add an element to an Enum field in an alembic migration when using a version of PostgreSQL older than 9.1 (which adds the ALTER TYPE for enums)? This SO question explains the direct process, but I’m not quite sure how best to translate that using alembic.

This is what I have:

JavaScript

The above unfortunately only produces ALTER TABLE testcaseresult ALTER COLUMN status TYPE status upon upgrade, which essentially does nothing.

Advertisement

Answer

I decided to try to follow the postgres approach as directly as possible and came up with the following migration.

JavaScript

It appears that alembic has no direct support for the USING statement in its alter_table method.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement