Flask回滚时出现AttributeError: 'NoneType' object has no attribute 'lower'
在做flask项目中的版本回退,时,出现了AttributeError: ‘NoneType’ object has no attribute ‘lower’
执行python 文件名.py db downgrade 版本号,后报错了,主要的报错内容如下:
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running downgrade 67e517bde18c ->bc447eaaaab1, test2
lc_value = value.lower()
AttributeError:’NoneType’ object has no attribute ‘lower’
解决办法:
在需要迁移的版本中, 有一个downgrade函数,其中有op.drop_constrain(None, ‘其他字段名’)
把None改成自己更改的字段名即可解决