For posterity, PostgreSQL >= 9.1 supports ALTER TYPE 
<http://www.postgresql.org/docs/9.1/static/sql-altertype.html> for 
ENUMs, although it cannot be executed within a transaction block. It's 
possible to set the isolation level to AUTOCOMMIT on the connection to emit 
the statement directly and do something like:

if not op.get_context().as_sql:
    connection = op.get_bind()
    connection.execution_options(isolation_level='AUTOCOMMIT')

op.execute("ALTER TYPE ck_custom_type ADD VALUE 'foo'")





On Wednesday, September 11, 2013 3:05:12 PM UTC-5, Michael Bayer wrote:
>
> just op.execute("ALTER TABLE hoho etc") 
>
> its PG specific anyway 
>
> unless you're trying to be database agnostic.   that would be more of a 
> PITA at this point.  I don't really use PG's ENUM I don't get the point of 
> all that fanfare. 
>
> On Sep 11, 2013, at 3:44 PM, Chris Withers <[email protected] 
> <javascript:>> wrote: 
>
> > It's actually ALTER that I'm interested in... 
> > 
> > How would I wire that into an Alembic upgrade script? 
> > 
> > Chris 
> > 
> > On 11/09/2013 15:21, Michael Bayer wrote: 
> >> 
> >> Alembic supports it but it isn't easy to use (and autogenerate won't 
> see it at all, most likely).   Postgresql's dialect has it's own ENUM type, 
> which features create() and drop()  methods of its own.  You have to use 
> those (or an equivalent) in your alembic script.   Postgreql wants to see 
> "CREATE TYPE... " here specifically, it's tedious. 
> >> 
> >> 
> >> On Sep 11, 2013, at 2:40 AM, Chris Withers <[email protected] 
> <javascript:>> wrote: 
> >> 
> >>> Hi Mike, 
> >>> 
> >>> Does Alembic support the Enum type with psycopg2? 
> >>> 
> >>> I'm specifically interested in whether or not --autogenerate will spot 
> additions or removals to the list of values in the enum and generate the 
> correct DDL to bring things back into line... 
> >>> 
> >>> cheers, 
> >>> 
> >>> Chris 
> >>> 
> >>> -- 
> >>> Simplistix - Content Management, Batch Processing & Python Consulting 
> >>>            - http://www.simplistix.co.uk 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to