Flask-whooshalchemy - 更改底层架构

时间:2015-01-19 01:11:55

标签: flask flask-sqlalchemy whoosh

将表列从post_text更改为post_text1时出现以下错误。我已更新我的模型并进行相应搜索

% (name, schema))
UnknownFieldError: No field named 'post_text1' in <Schema: ['id', 'post_text']>

继承文件:

class Post(db.Model):
    __searchable__ = ['post_text1', 'post_text2', 'post_text3']

    id = db.Column(db.Integer, primary_key=True)
    post_type = db.Column(db.String(256))
    post_text1 = db.Column(db.String(256))
    post_text2 = db.Column(db.String(256))
    post_text3 = db.Column(db.String(256))
    post_source = db.Column(db.String(256))
    post_time = db.Column(db.Integer)
    number_of_replies = db.Column(db.Integer)
    post_score = db.Column(db.Integer)
    post_rank = db.Column(db.Integer)
    flagged = db.Column(db.Integer)
    admin_post = db.Column(db.Boolean)
    company_name = db.Column(db.String(64))
    division = db.Column(db.String(64))
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    user_name = db.Column(db.String(256))

    def __repr__(self):
        return '<Post %r>' % (self.post_text1)

    def as_dict(self):
      return {c.name: getattr(self, c.name) for c in self.__table__.columns}

连连呢?我尝试卸载并重新安装,但似乎卸载仍保留旧架构。

1 个答案:

答案 0 :(得分:1)

我遇到了同样的错误,并且能够通过删除飞快生成的whoosh_index目录来修复它。