Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db migrate success, but db upgrade fail, what can i do next? #444

Closed
meimeitou opened this issue Oct 28, 2021 · 3 comments
Closed

db migrate success, but db upgrade fail, what can i do next? #444

meimeitou opened this issue Oct 28, 2021 · 3 comments
Labels

Comments

@meimeitou
Copy link

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.

@miguelgrinberg
Copy link
Owner

Delete the bad migration file (the one that failed to upgrade), then you should be able to run flask db migrate again.

@meimeitou
Copy link
Author

Delete the bad migration file (the one that failed to upgrade), then you should be able to run flask db migrate again.

flask db history, have the migrate version

so i should delete migrations file in project and delete version history in db ?

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented Oct 28, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants