Opened 5 years ago
Closed 5 years ago
#30935 closed Bug (invalid)
Problem with makemigrations/migrate (AUTH_USER_MODEL) and duplication of tables.
Reported by: | Man Python | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 2.2 |
Severity: | Normal | Keywords: | makemigrations migrate |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Change History (1)
comment:1 by , 5 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Summary: | Problem with makemigrations/migrate (AUTH_USER_MODEL) and duplication of tables → Problem with makemigrations/migrate (AUTH_USER_MODEL) and duplication of tables. |
Please try to be more specific in the future, it's hard to tell what kind of issue you were trying to describe when reading:
Soo.. migrations/migrate working not correct in v1.1 and 2.2 around this and more.
There is many issues related with this...
I touching many problems on DJ 2.2 in small prototypes.
You should start from the official Django's tutorials and documentation. Please don't use trac as a support channel.
Closing per TicketClosingReasons/UseSupportChannels.