On an app I am running multiple migrations from 0023-0027 in one go. But the first of the migration is complaining that it is missing a column that is not introduced until later.
Running migrations for blogs:
- Migrating forwards to 0027_auto
> blogs:0023_auto
Error in migration: blogs:0023_auto
the error reads:
django.db.utils.DatabaseError: column blogs_blog.author_bio does not exist
LINE 1: ...log"."author_name", "blogs_bl...
So any idea why migration 0023 would fail with missing a column that is not introduced until migration 0027?
The problem was that the auto-generated 0023 migration in the forwards function had the following in it:
for a in Blog.objects.all():
a.uuid = u'' + str(uuid.uuid1().hex)
a.save()
that calls the model based on the latest content, so author_bio was in it. To fix it then call the model from the "orm" like so:
for a in orm.Blog.objects.all():
a.uuid = u'' + str(uuid.uuid1().hex)
a.save()