我有一个 Flask 模型:
class User(db.Model):
ROLE_USER = 0
ROLE_MODERATOR = 1
ROLE_ADMIN = 2
ROLES = [
(ROLE_USER, u'Regular user'),
(ROLE_MODERATOR, u'Moderator'),
(ROLE_ADMIN, u'Admin')
]
id = db.Column(db.Integer, primary_key = True)
login = db.Column(db.String(32), nullable=False, unique=True)
first_name = db.Column(db.String(32))
last_name = db.Column(db.String(32))
role = db.Column(ChoiceType(ROLES), nullable=False)
我用flask-migrate创建了一个迁移(db是Postgresql):
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('login', sa.String(length=32), nullable=False),
sa.Column('first_name', sa.String(length=32), nullable=True),
sa.Column('last_name', sa.String(length=32), nullable=True),
sa.Column('role', sqlalchemy_utils.types.choice.ChoiceType(length=255), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('login')
)
迁移已成功创建,但是当我要升级时,出现此错误:
TypeError: <flask_script.commands.Command object at 0x7fada1e973d0>: __init__() got an unexpected keyword argument 'length'
有人可以解释这个问题吗?