Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25100 closed Cleanup/optimization (fixed)

Document how to avoid ""RuntimeError: Error creating new content types." when upgrading to 1.8 (skipping 1.7)

Reported by: Sachin philip Mathew Owned by: nobody
Component: Documentation Version: 1.8
Severity: Normal Keywords: contentype migration
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

  • Project Build on django 1.4.10
  • Database - postgresql (which got large amount data)

Steps to Reproduce issues

  1. Upgraded to django 1.8.*
  2. Create a new table
  3. executing makemigrations works fine
  4. when we migrate, migrations works and gives ok response then followed by

"Error creating new content types. Please make sure contenttypes "
RuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually.

  1. Then try to access this table from admin it gives responce

Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually.

  1. tried migrate contenttype - nothing changes
  1. Downgraded to django 1.7 , and executing migration for contenttype works and issue will be resolved

Each and everytime we need to follow this same process not just once, each and everytime when we create a new table not column

Attachments (1)

Screen Shot 2015-07-10 at 6.07.48 pm copy.jpg (151.8 KB ) - added by Sachin philip Mathew 9 years ago.
Migration error responce

Download all attachments as: .zip

Change History (10)

by Sachin philip Mathew, 9 years ago

Migration error responce

comment:1 by Tim Graham, 9 years ago

Component: MigrationsDocumentation
Summary: cant migrate contenttype with django 1.8 when new table is createdDocument how to avoid ""RuntimeError: Error creating new content types." when upgrading to 1.8 (skipping 1.7)
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

Please see if https://groups.google.com/d/topic/django-users/DlRQOdsJL6o/discussion helps. Are you faking the contenttypes migrations which causes both 0001 and 0002 to be faked? Maybe we could add a tip about this in the 1.8 release notes since it seems to be a common issue. migrate --fake-initial might resolve that.

comment:2 by Sachin philip Mathew, 9 years ago

No i am not faking it

This is what really happens in 1.8

i try migrate --fake-initial - it didnt work

Response:
It says Your models have changes that are not yet reflected in a migration, and so won't be applied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

with the same bunch of contenttype errors

Only Solution i really found was Downgrading to 1.7.* and migrating contenttypes individually

migrate contenttypes

Response will be the same
It says Your models have changes that are not yet reflected in a migration, and so won't be applied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

but there wont be any errors and issue will be solves temporarily

Note: now we can goback to 1.8 and go on with the developments . Migrations wont have any issue in 1.8 untill we add a new table(i didnt find any issues with columns ). If we add new table we should again do the same procedures .

comment:3 by Tim Graham, 9 years ago

Resolution: needsinfo
Status: newclosed

I'm not sure what's going on, and I think we need a sample project to reproduce the issue.

comment:4 by Tim Graham, 9 years ago

Easy pickings: set
Resolution: needsinfo
Status: closednew

Steps to reproduce:
1) Have a pre-1.7 project.
2) Upgrade to Django 1.8 (skipping 1.7) and run manage.py migrate --fake.
3) Now, 0002_remove_content_type_name.py will get fake-applied and the name column in the django_content_type table won't be dropped.

We should recommend using migrate --fake-initial in the 1.8 release notes for this case.

comment:5 by Tim Graham, 9 years ago

Has patch: set

comment:6 by Claude Paroz, 9 years ago

Triage Stage: AcceptedReady for checkin

comment:7 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: newclosed

In 81b55fb:

Fixed #25100 -- Documented an upgrade caveat for contenttypes migration.

comment:8 by Tim Graham <timograham@…>, 9 years ago

In 8b1c386:

[1.9.x] Fixed #25100 -- Documented an upgrade caveat for contenttypes migration.

Backport of 81b55fb90078788bfdc064550f2ff9da2c79d3b6 from master

comment:9 by Tim Graham <timograham@…>, 9 years ago

In 052bd3f:

[1.8.x] Fixed #25100 -- Documented an upgrade caveat for contenttypes migration.

Backport of 81b55fb90078788bfdc064550f2ff9da2c79d3b6 from master

Note: See TracTickets for help on using tickets.
Back to Top