我有以下设置
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'}
现在我使用alembic删除了Locality表。 每次我查询内容时,我都会
AssertionError: No such polymorphic_identity 'city' is defined
如何删除此polymorphic_identity
答案 0 :(得分:0)
我通过MySQL控制台对内容应用MySQL'delete from'命令,找到类型为'city'的内容
来解决这个问题delete from content where content.type='city';