I somehow screwed up my migrations when creating the database for a new project. I now have the problem of migrations that don't apply:
Operations to perform:
Apply all migrations: wagtailusers, wagtailembeds, wagtailadmin, sessions, admin, wagtailcore, auth, contenttypes, wagtaildocs, taggit, wagtailsearch, home, wagtailforms, wagtailredirects, wagtailimages
Running migrations:
No migrations to apply.
Based on this answer (and a few others), it seems like my best bet is to clear stuff out of the django_migrations
table. So I ran:
DELETE FROM django_migrations WHERE app='wagtailusers';
and got the error:
ERROR: relation "django_migrations" does not exist
How can django_migrations not exist? What am I doing wrong? I basically want to scrub everything in the database and all the migrations and start over from scratch, but it's apparently far more complicated than I suspected. (Is there a simpler way to basically start over with the database and migrations?)
EDIT:
I tried reverting one app and migrating it forward again.
I ran ./manage.py showmigrations wagtailusers
, which showed all migrations applied:
wagtailusers
[X] 0001_initial
[X] 0002_add_verbose_name_on_userprofile
[X] 0003_add_verbose_names
[X] 0004_capitalizeverbose
I then unapplied all of the migrations with ./manage.py migrate wagtailusers zero
:
Operations to perform:
Unapply all migrations: wagtailusers
Running migrations:
Rendering model states... DONE
Unapplying wagtailusers.0004_capitalizeverbose... OK
Unapplying wagtailusers.0003_add_verbose_names... OK
Unapplying wagtailusers.0002_add_verbose_name_on_userprofile... OK
Unapplying wagtailusers.0001_initial... OK
showmigrations
then shows them all unapplied. So I then reapply the migrations with ./manage.py migrate wagtailusers
:
Operations to perform:
Apply all migrations: wagtailusers
Running migrations:
Rendering model states... DONE
Applying wagtailusers.0001_initial... OK
Applying wagtailusers.0002_add_verbose_name_on_userprofile... OK
Applying wagtailusers.0003_add_verbose_names... OK
Applying wagtailusers.0004_capitalizeverbose... OK
Everything is checked in showmigrations
. But when I run migrate again, it still seems to think there's something missing?
Operations to perform:
Apply all migrations: wagtailusers
Running migrations:
No migrations to apply.