I accidentally deleted my migrations folder. So I ran flask db init
, and everything ran smoothly. But when I ran flask db migrate
, it gave me this error:
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
ERROR [root] Error: Can't locate revision identified by '470572fac7a1'
From what I understand, it's looking for my other migration folder which is long gone. How can I solve this?
Delete that particular record in the table alembic_version that's in your database. There's only one varchar column called version_num, so this expression should work:
delete from alembic_version where version_num='470572fac7a1';
Delete the /migrations
directory and rename/replicate your applications database. Then start from scratch.
flask db init
flask db migrate
flask db upgrade
Now repopulate your new empty database with data from your backup.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With