On Apr 10, 2014, at 1:12 PM, Nguyễn Hồng Quân <ng.hong.q...@gmail.com> wrote:

> 
> Before,  I had gender_type declared inline in model A (gender = 
> Column(Enum('male', 'female', name='gender_type'))).
> Now I add model B and also want to reuse the gender_type in model A. So, I 
> bring gender_type out and link to it from model A & B. But when I use Alembic 
> to create migration script, I got this for  model B (new-added):
> 
> def upgrade():
>     ...
>     gender = sa.Column('gender', sa.Enum('male', 'female', 
> name='gender_types'), nullable=True)
>     ...
> 
> It means the migration script tries to create new Enum, instead reuse it.
> How should I edit the migration script to make it do what I want?


use the PG ENUM type instead and add create_type=False:

from sqlalchemy.dialects.postgresql import ENUM

ENUM(‘male’, ‘female’, name=‘gt’, create_type=False)


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to