2015-11-10 13 views
0

我有以下设置蒸馏器迁移:如何删除多态性身份

class Content(Base): 
    """Content object""" 
    __tablename__ = "content" 
    id = Column(Integer, primary_key=True) 
    name = Column(Unicode(255),unique=True, nullable=False) 
    title = Column(Unicode(255)) 
    body = Column(UnicodeText) 
    created = Column(DateTime, default=func.now()) 
    modified = Column(DateTime, onupdate=func.now()) 
    type = Column(String(20)) 
    __mapper_args__ = { 
    'polymorphic_on':type, 
    'polymorphic_identity':'content', 
    'with_polymorphic':'*' 
} 


class Locality(Content): 
    __tablename__ = "local" 
    id = Column(Integer, ForeignKey('content.id'),primary_key=True) 

    city_name = Column(Unicode(80)) 
    __mapper_args__ = {'polymorphic_identity':'city'} 

现在我使用蒸馏器下降的位置表。 每次我查询内容,我得到

AssertionError: No such polymorphic_identity 'city' is defined 

如何退出这个polymorphic_identity

回答

0

我得到了这个应用MySQL命令通过MySQL的控制台内容“从删除”,发现其类型的内容是'城市'

delete from content where content.type='city';