野声

Hey, 野声!

谁有天大力气可以拎着自己飞呀
twitter
github

Flask-Migrate migration not working

Spent the whole night to solve this problem.

I wanted to use the flask-migrate plugin for database version management, but I kept encountering this issue.

INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.env] No changes in schema detected.

I have tried various methods, importing the content from models in every place, adjusting the use of flask script, and so on...

Solution#

Because my database has already been started, my database is consistent with the content in models.
So this sentence won't take effect...

Therefore, the best time to migrate is before establishing the database...

Then I started from scratch, and after deleting the database, the migration was successful.

Other Pitfalls#

I noticed that most of the issues encountered by other users were due to not importing the content from models, so this needs to be taken into account.

Be careful not to have circular dependencies.

Migrate should be done after db.init.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.