miguelgrinberg / microblog

The microblogging application developed in my Flask Mega-Tutorial series. This version maps to the 2024 Edition of the tutorial.
http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
MIT License
4.56k stars 1.65k forks source link

Chapter 4: Problem with 'flask db downgrade base' #397

Open DRuyters opened 3 months ago

DRuyters commented 3 months ago

Hello,

When trying to downgrade the database, I get the following error:

"Cannot drop index 'ix_post_user_id': needed in a foreign key constraint"

I assume that I need to change something in one of the migrations files to solve this problem. I am running a local MySQL server so it might be related to that

miguelgrinberg commented 3 months ago

If this happens with the "posts table" migration included in this project, then my guess is that there is some small difference between sqlite (which is what I used when the migrations were generated) and MySQL. You can try moving the drop table call to the top to see if that helps.