#23519: Invalid ContentType after running "migrate" command
----------------------------+--------------------
Reporter: humitos | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
Hi folks!
First of all, I'm not sure if this is a Django bug o something in my code
(or 3rd app code). I tried debugging it by myself but I didn't get to the
right port. So, I'm asking here.
For some reason, after running "migrate" in a fresh db everything works
fine but the second time it's ran (immediately after the first one has
finished and the subsequents) I got this message:
{{{
$ ./manage.py migrate
Operations to perform:
Synchronize unmigrated apps: facebook_comments, stronghold, dbtemplates,
django_comments, django_proofread, allauth, guardian, autocomplete_light,
debug_toolbar, dbsettings, chap, django_extensions, impersonate,
django_wysiwyg, disqus, notifier, crispy_forms
Apply all migrations: core, account, reversion, league, admin,
challenge, sessions, sites, auth, sponsor, notifications, contenttypes,
flatpages, team, organization, easy_thumbnails, inspiration
Synchronizing apps without migrations:
Creating tables...
Installing custom SQL...
Installing indexes...
Running migrations:
No migrations to apply.
The following content types are stale and need to be deleted:
core |
Any objects related to these content types by a foreign key will also
be deleted. Are you sure you want to delete these content types?
If you're unsure, answer 'no'.
Type 'yes' to continue, or 'no' to cancel: yes
$
}}}
These are the differences in the db dump files (after first "migrate"
command compared with the second run):
http://linkode.org/9OjIVmwW3YDDM4pTabHWX1
{{{
--- chap-migration-test.sql 2014-09-18 09:31:58.332672674 -0300
+++ chap-migration-test-after-2nd-migrate.sql 2014-09-18
09:32:17.148672191 -0300
@@ -2756,7 +2756,6 @@
49 Can add registration invitation 16 add_registrationinvitation
50 Can change registration invitation 16
change_registrationinvitation
51 Can delete registration invitation 16
delete_registrationinvitation
-52 Can edit core non-model settings 17 can_edit__settings
53 Can add user 18 add_user
54 Can change user 18 change_user
55 Can delete user 18 delete_user
@@ -2909,6 +2908,7 @@
202 Can add group object permission 67 add_groupobjectpermission
203 Can change group object permission 67
change_groupobjectpermission
204 Can delete group object permission 67
delete_groupobjectpermission
+205 Can edit core non-model settings 68 can_edit__settings
\.
@@ -2916,7 +2916,7 @@
-- Name: auth_permission_id_seq; Type: SEQUENCE SET; Schema: public;
Owner: postgres
--
-SELECT pg_catalog.setval('auth_permission_id_seq', 204, true);
+SELECT pg_catalog.setval('auth_permission_id_seq', 205, true);
--
@@ -3279,7 +3279,6 @@
14 report core report
15 rule core rule
16 registration invitation core registrationinvitation
-17 core core
18 user challenge user
19 goal challenge goal
20 user goal challenge usergoal
@@ -3330,6 +3329,7 @@
65 notification notifier notification
66 user object permission guardian userobjectpermission
67 group object permission guardian groupobjectpermission
+68 core core
\.
@@ -3337,7 +3337,7 @@
-- Name: django_content_type_id_seq; Type: SEQUENCE SET; Schema: public;
Owner: postgres
--
-SELECT pg_catalog.setval('django_content_type_id_seq', 67, true);
+SELECT pg_catalog.setval('django_content_type_id_seq', 68, true);
--
}}}
and another diff between the second and the third time:
http://linkode.org/rX21iFzHICntF4ergjEcW5
{{{
--- chap-migration-test-after-2nd-migrate.sql 2014-09-18
09:32:17.148672191 -0300
+++ chap-migration-test-after-3rd-migrate.sql 2014-09-18
09:37:38.948663938 -0300
@@ -2908,7 +2908,7 @@
202 Can add group object permission 67 add_groupobjectpermission
203 Can change group object permission 67
change_groupobjectpermission
204 Can delete group object permission 67
delete_groupobjectpermission
-205 Can edit core non-model settings 68 can_edit__settings
+206 Can edit core non-model settings 69 can_edit__settings
\.
@@ -2916,7 +2916,7 @@
-- Name: auth_permission_id_seq; Type: SEQUENCE SET; Schema: public;
Owner: postgres
--
-SELECT pg_catalog.setval('auth_permission_id_seq', 205, true);
+SELECT pg_catalog.setval('auth_permission_id_seq', 206, true);
--
@@ -3329,7 +3329,7 @@
65 notification notifier notification
66 user object permission guardian userobjectpermission
67 group object permission guardian groupobjectpermission
-68 core core
+69 core core
\.
@@ -3337,7 +3337,7 @@
-- Name: django_content_type_id_seq; Type: SEQUENCE SET; Schema: public;
Owner: postgres
--
-SELECT pg_catalog.setval('django_content_type_id_seq', 68, true);
+SELECT pg_catalog.setval('django_content_type_id_seq', 69, true);
--
}}}
I found that !ContentType is marked to be removed for some reason here:
https://github.com/django/django/blob/stable/1.7.x/django/contrib/contenttypes/management.py#L41
. Although, I couldn't find the real reason. In fact, I couldn't find why
the {{{model}}} attribute for that !ContentType is {{{''}}}.
Another thing that I noticed is that I remove one of the 3rd apps I'm
using (django-dbsettings==0.7) from {{{INSTALLED_APPS}}} and run "migrate"
again, I get that message but after answering {{{yes}}} Django doesn't ask
me again about that.
I tried creating a new project from scratch and installing django-
dbsettings, create some models, run "makemigrations", "migrate", delete
some models, "makemigrations", "migrate" and so... but I didn't get that
error in this new project.
I'm confused and I couldn't get with the solution. I'm not sure if this is
something related with django itself or if it's just my code.
--
Ticket URL: <https://code.djangoproject.com/ticket/23519>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.94a9dcf9db06313c58b2f1a04d825644%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.