sqlalchemy / sqlalchemy/alembic

Autogenerate doesn't correctly handle postgresql enums

Open
#278 37 comments 83 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

autogenerate for enums bug data types postgresql
Dominant language
Python
Stars
4.4k
Forks
375
PR merge metrics
No merged PRs in 30d

Description

Migrated issue, originally created by Ulrich Petri (@ulope)

According to #67 enum types used in columns have to be explicitly created and destroyed.

However the autogenerator currently doesn't produce those explicit commands. This problem is made worse by the fact that the autogenerated migration appears to work fine the first time it is applied and even removed. The dangling enum type only causes a conflict the second time the migration is applied.

edit by mike: note also that anything we do for PG native enums also has to run outside of a transaction block, so this is really not going to be easy. #123 provides the feature for this however if autogenerate, or the operation itself, is going to make that happen automatically, that's a very dramatic behavior.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the autogenerator’s handling of PostgreSQL enum types, then read issue #67 for the required explicit create/drop behavior and #123 for transaction handling. Done means regenerated migrations manage enum types explicitly and account for the requirement that native-enum operations run outside a transaction block.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.