flask migrate时报错 Can't locate revision identified by '3d80e4c025df'
flask 迁移数据库时可能会遇到找不到版本的问题
export FLASK_APP=run.py
flask db migrate
执行上述命令时正常会提示加了哪些字段,删除了哪些字段
但是有时候会提示:
ERROR [flask_migrate] Error: Can't locate revision identified by '3d80e4c025df'
修复方法: 给指定一个版本号
flask db revision --rev-id 3d80e4c025df
然后执行迁移 flask db migrate
flask db migrate
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.autogenerate.compare] Detected removed column 'asset_IP.province_name'
INFO [alembic.autogenerate.compare] Detected removed column 'asset_IP.province'
INFO [alembic.autogenerate.compare] Detected removed column 'asset_IP.city_name'
INFO [alembic.autogenerate.compare] Detected removed column 'asset_IP.city'
INFO [alembic.autogenerate.compare] Detected added column 'organization.province'
INFO [alembic.autogenerate.compare] Detected added column 'organization.province_name'
INFO [alembic.autogenerate.compare] Detected added column 'organization.city'
INFO [alembic.autogenerate.compare] Detected added column 'organization.city_name'
再执行升级 flask db upgrade
flask db upgrade
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade 3d80e4c025df -> 87a8d47a7d0a, empty message

浙公网安备 33010602011771号