Flask-Migrate
Flask-Migrate copied to clipboard
`db migrate` success, but `db upgrade` fail, what can i do next?
run
flask db migrate
# return success
# then
flask db upgrade
# return failed
# o my models file define error, so i corrected it.
# then run
flask db migrate
# return: ERROR [flask_migrate] Error: Target database is not up to date.
What do I do in this case next?
i fix models file, but can’t migrate or upgrade again.
one way is delete all file, and db init again, but this is not what I want.
Delete the bad migration file (the one that failed to upgrade), then you should be able to run flask db migrate again.
Delete the bad migration file (the one that failed to upgrade), then you should be able to run
flask db migrateagain.
flask db history, have the migrate version
so i should delete migrations file in project and delete version history in db ?
You should delete the migration file that fails to upgrade. Just that one file. It is going to be listed as the latest migration script in the history report. If you run flask db current you will have a different migration as the current migration installed in your database (the previous one), so this failing migration script is not referenced by your database and can be deleted and recreated after you fix the problem.