from sqlalchemy import *
from migrate import *
meta = MetaData()
race_enums = ('asian','mideastern','black','nativeamerican','indian','pacific','hispanic','white','other');
profiles_profiles = Table(
'profiles_profiles', meta,
Column('id', Integer, primary_key = True),
Column('user_id', Integer, nullable=False, unique=True),
Column('race', Enum, race_enums),
Column('summary', Text, nullable= True),
Column('my_life', Text, nullable= True),
Column('to_do', Text, nullable= True),
Column('favs', Text, nullable= True),
Column('created_at', DateTime, nullable=True),
Column('updated_at', DateTime, nullable=True)
)
def upgrade(migrate_engine):
meta.bind = migrate_engine
profiles_profiles.create()
pass
def downgrade(migrate_engine):
meta.bind = migrate_engine
profiles_profiles.drop()
pass
When I manage.py upgrade this, I get this error:
AttributeError: 'tuple' object has no attribute '_set_parent_with_dispatch'
You need pass race_enum
as an argument for Enum
, not Column
You can either pass in your tuple
as whole
Column('race', Enum('asian','mideastern','black','nativeamerican','indian','pacific','hispanic','white','other'))
or use *
to unpack race_enums
:
Column('race', Enum(*race_enums))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With