Target database is not up to date

前端 未结 11 1159
别那么骄傲
别那么骄傲 2020-12-12 16:54

I\'d like to make a migration for a Flask app. I am using Alembic.

However, I receive the following error.

T         


        
相关标签:
11条回答
  • 2020-12-12 17:26

    This can be solved bby many ways :

    1 To fix this error, delete the latest migration file ( a python file) then try to perform a migration afresh.

    If issue still persists try these commands :

    $ flask db stamp head  # To set the revision in the database to the head, without performing any migrations. You can change head to the required change you want.
    $ flask db migrate     # To detect automatically all the changes.
    $ flask db upgrade     # To apply all the changes.
    
    0 讨论(0)
  • 2020-12-12 17:27

    Try to drop all tables before execute the db upgrade command.

    0 讨论(0)
  • 2020-12-12 17:30

    I did too run into different heads and I wanted to change one of the fields from string to integer, so first run:

    $ flask db stamp head # to make the current the same
    $ flask db migrate
    $ flask db upgrade
    

    It's solved now!

    0 讨论(0)
  • 2020-12-12 17:34

    This Worked For me

    $ flask db stamp head
    $ flask db migrate
    $ flask db upgrade
    
    0 讨论(0)
  • 2020-12-12 17:38
    $ flask db stamp head  # To set the revision in the database to the head, without performing any migrations. You can change head to the required change you want.
    $ flask db migrate  # To detect automatically all the changes.
    $ flask db upgrade  # To apply all the changes.
    

    You can find more info at the documentation https://flask-migrate.readthedocs.io/en/latest/

    0 讨论(0)
提交回复
热议问题