ERROR [alembic.env] name 'Text' is not defined upon 'python manage.py db upgrade'

余生长醉 提交于 2019-12-11 06:08:31

问题


Replicating this link to first test the feasibility of DB migration..

This turns out to be a bug in Alembic, and I tried adding from sqlalchemy.types import Text to no avail. This link is supposed to be a fix, but I cannot quite see which part of the code I can use for my purpose.

from alembic import autogenerate
from app import db
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import JSON
from sqlalchemy import Integer, String, TIMESTAMP
from sqlalchemy.types import Text

class Result(db.Model):
    __tablename__ = 'results'

    id = db.Column(Integer, primary_key = True)
    url = db.Column(sa.String())
    result_all = db.Column(JSON)
    result_no_stop_words = db.Column(JSON)

    def __init__(self, url, result_all, result_no_stop_words):
        self.url = url
        self.result_all = result_all
        self.result_no_stop_words = result_no_stop_words

    def __repr__(self):
        return('<id {}>'.format(self.id))

This, should not return an error. I tried with JSON(astext_type=Text()) and JSON(astext_type=sa.Text()) instead of JSON too, within db.Column bracket.

来源:https://stackoverflow.com/questions/54409817/error-alembic-env-name-text-is-not-defined-upon-python-manage-py-db-upgrade

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!