[Python] Handling PostgreSQL ENUM types in SQLAlchemy and Alembic migrations

Discussão em 'Python' iniciado por Stack, Março 21, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to implement PostgreSQL ENUM types properly in my SQLAlchemy models and Alembic migrations. I am stuck on this one specific part:

    How do I handle creating the enum type in migrations before it's used in tables?

    I want to keep SQL Alchemy as a single source of truth, so adding in ad-hoc migrations to fill in the gaps from SQL Alchemy definitions makes it very hard to maintain what the current schema is by looking at the code alone.

    Thanks in advance

    Continue reading...

Compartilhe esta Página