-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
alembic stuck on database upgrade #41
Comments
What was your fix? I'm having the same issue! |
I can't quite remember, but I reckon you could squash the migration by deleting it (since it's not committed) and redoing the migrate and upgrade steps again. |
Thanks for the reply - worked it out in the end: |
@authentik8 Had the same problem, thanks ! 👍 |
No problem, put up an explanation for exactly that reason! In reply to your PS, no (I was out for one of the middle days anyway!) - I got as far as working out that if I killed and recreated my tmux session whenever it hung then I could get it to work. Obviously the issue was intermittent as I only had a flask shell open some of the time, but it worked "well enough" for a while. Eventually I got tired of having to reconfigure all of my panes after every time it hung, so I decided to stop developing more stuff until I resolved it. Took me about 15 minutes of playing around with different things until I could isolate the cause (which then made sense, reading the SQLAlchemy docs on how sessions work). |
Yep, this should have been obvious, ha!. |
This is happening also because of thread with an infinite loop (intentionally for checking some kind of event), |
@samakshjain Thank you for saying so. I use gnu screen as well, and that was the exact problem! Also facepalm |
Just adding this as a potential cause: |
For those who want to run alembic upgrade when app is running, add the following code in your project's app file.
the variable db is the database session from your database setting file. so you should import it first. When alembic runs, it uses flask's app context, and the currently running app is holding all connections, which means there are no available connections for alembic to use. |
For me, it's because the type tinyint and bool are the same thing in mysql but alembic sees them differently, so every time I upgrade it stuck. See here for more detail. |
Same issue - for me I had one of my tables misspelled such as in |
I'm running a database migration, and Alembic complains with
alembic.util.CommandError: Target database is not up to date.
So and I then run a database upgrade
python manage.py db upgrade
Here is the output:
INFO [alembic.migration] Context impl PostgresqlImpl.
INFO [alembic.migration] Will assume transactional DDL.
INFO [alembic.migration] Running upgrade 604497a5e5 -> 431e33e6fce, empty message
The issue is that Alembic never finishes the upgrade (never quits the terminal) and it appears stuck on the third step, I have tried severally, even leaving it for several minutes but it never completes the upgrade.
I have tried running this locally and on the server and it doesn't work (it's not an issue with the connection).
The text was updated successfully, but these errors were encountered: