Can't migrate or upgrade database with Flask-Migrate (Alembic)

后端 未结 4 639
说谎
说谎 2021-02-13 07:21

I\'ve been using Flask-Migrate (Alembic) for updating my database. I updated my models.py file however I made an error. I ran a migration and went to upgrade the da

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-13 07:54

    Alembic stores the db version in a table it creates called alembic_version. This table contains a single field and row alembic_version.version_num. Make sure the value for this matches the filename of the most recent file in migrations/version. This version number is also contained inside the revision file in the revision variable that generally shows up on line 26 of the file. Make sure it matches the db version.

    Another option is to simply drop the db and recreate it using alembic. If this is a development environment, where the data is not important, that would be my recommendation.

提交回复
热议问题