carl
carl

Reputation: 4436

flask-migrate: can't upgrade database becase "table does not exist"

I am working on a flask application using sqlalchemy with a postgres database. I am migrating my databsed with flask-migrate. I had to change the name of one of my tables in the database and when trying to migrate (flask-migrate) I got an error

sqlalchemy.exc.InternalError: (psycopg2.InternalError) cannot drop table category_announcement_date because other objects depend on it
DETAIL:  constraint announcement_dates_id_fkey on table announcement_dates depends on table category_announcement_date
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
[SQL: '\nDROP TABLE category_announcement_date']

I did not know how to tell flask-migrate about this issue so I came up with the great idea to do it manually so I went to psql and dropped the table together with the CASCADE command as suggested by the error message. That all worked fine but now I can't finish the migration? When running upgrade I get

python manage.py db upgrade
...
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) table "category_announcement_date" does not exist

which is probably because I just dropped the table manually? Does anybody know how I can get out of this mess? thanks carl

Upvotes: 2

Views: 1098

Answers (1)

carl
carl

Reputation: 4436

ok I noticed deleting the version files and repeating the migrate does the trick cheers fl

Upvotes: 1

Related Questions