#24524: Automatic migrations prevent creation of initial database table layout -------------------------------------+------------------------------------- Reporter: SimonSteinberger | Owner: nobody Type: | Status: closed Cleanup/optimization | Component: Migrations | Version: 1.8rc1 Severity: Normal | Resolution: | worksforme Keywords: migrations, fail, | Triage Stage: collision | Unreviewed Has patch: 0 | Needs documentation: 1 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by jbrendel): I have the same problem, but the suggested solution does not work for me, unfortunately. Specifically, it's a 1.7.6 application (backed by Postgres), which I would like to update to 1.8.9. I'm currently happy to completely reset the database, so there are no changes, I just need the initial schema creation. There are NO migrations in any of my apps, so no 'migrations' folders exist anywhere. I also have a custom user model (inheriting from 'AbstractUser'). When I do as suggested (`python manage.py makemigrations <appname>`), some migrations are created (even though there is no DB that might require migrations), but the subsequent 'migrate' still fails. Needless to say, this worked well for me on 1.7.6, but I'm now completely stuck with 1.8.9. One additional bit of information: I can get the migrations to finally run through with the following hacky procedure: 1. `python manage.py makemigrations <my-app-with-customer-user-model>`. 2. `python manage.py migrate <my-app-with-customer-user-model>`. This ends with `django.db.utils.ProgrammingError: relation "django_site" does not exist`, but we'll continue anyway... 3. `python manage.py migrate`. Runs through without error. I need to make sure to have 'sites' listed before 'contentype' in my settings file. During step (2) a few tables are created, even though it eventually fails. Specifically, the "contenttypes" and "auth" related tables. This is important, since without "contenttypes" I can't migrate sites and without auth I can't migrate contenttypes. The only way I found to create those tables is by running a failed migration attempt for my app. There doesn't seem to be a way to create those tables in a way that doesn't result in an error at some point, due to what appears to be some sort of circular dependency between sites, contentypes and auth. Of course, such a hacky work-around is not really useful, since the test- database can't be created in that manner (its automated creation needs to work without hack). It seems I at least need to get this to the stage where I can just run `python manage.py migrate` (or `syncdb` for that matter, which also fails since it needs my app with the custom user model). Any help or insight would be greatly appreciated. Thank you very much! -- Ticket URL: <https://code.djangoproject.com/ticket/24524#comment:10> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/074.1a1f0fcedae037ee56799769c9fbd14a%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.