﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30935	Problem with makemigrations/migrate (AUTH_USER_MODEL) and duplication of tables.	Man Python	nobody	"I noticed problem for migrations/migrate in DJ 2.2 in case of CustomUser.
Eg. following for the example
https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html
DJ 2.2 not accepting for `AUTH_USER_MODEL = 'app.classname'` in ` settings.py ` as error:

{{{
 raise AppRegistryNotReady(""Apps aren't loaded yet."")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
}}}
There is hundred isses on internet with this.. and no sense sugestions
https://stackoverflow.com/questions/34114427/django-upgrading-to-1-9-error-appregistrynotready-apps-arent-loaded-yet
https://stackoverflow.com/questions/48163641/django-core-exceptions-appregistrynotready-apps-arent-loaded-yet-django-2-0
https://stackoverflow.com/questions/33186413/djangodjango-core-exceptions-appregistrynotready-apps-arent-loaded-yet
https://stackoverflow.com/questions/48163641/django-core-exceptions-appregistrynotready-apps-arent-loaded-yet-django-2-0/48168360

I compared this situation with previous DJ versions 1.1 and discoverd that in ` settings.py ` the changes in `AUTH_USER_MODEL` are not included/recognized, not saved. HVR the v.1.1 of DJ the `AUTH_USER_MODEL` showing in error old var in case that value of this var is other (new/diffrent), that allow discover the error on Dj 2.2 that is similar.

In some case of this there is related problem with SECRET_KEY that made false way of understandig the real problem


Soo.. migrations/migrate working not correct in v1.1 and 2.2 around this ande more.
There is many issues related with this. Eg. modify some classes on model, registered and next deleted made that table is not deleted or renamed, specially  something like this:
`user_type = models.ForeignKey(AccountsType, related_name='x_types_user', on_delete=models.CASCADE, default=None, null=True)`
If comented `user_type` as not used more and makemigrations/migrate then not deleted from mysql and when turn back this line/row of code then error:
{{{
mysql.connection.query(self, query)
django.db.utils.OperationalError: (1060, ""Duplicate column name 'user_type '"")
}}}

This all made ORM strategy hard to trust in manage dev stage, specially if apps are huge/advanced. HVR I touching many problems on DJ 2.2 in small prototypes. "	Bug	closed	Migrations	2.2	Normal	invalid	makemigrations migrate		Unreviewed	0	0	0	0	0	0
