Hi everyone,

Vital stats: MySQL, python 3.5, Ubuntu, not using South.

I'm upgrading from 1.9.5 to 1.11.8, and in amongst that there is a 
migration to change to username field length in auth:

auth
 [X] 0001_initial
 [X] 0002_alter_permission_name_max_length
 [X] 0003_alter_user_email_max_length
 [X] 0004_alter_user_username_opts
 [X] 0005_alter_user_last_login_null
 [X] 0006_require_contenttypes_0002
 [X] 0007_alter_validators_add_error_messages
 [ ] 0008_alter_user_username_max_length

That migration fails with the following message:

django.db.utils.IntegrityError: (1452, 'Cannot add or update a child row: a 
foreign key constraint fails (`tenant_fibrhealth`.`#sql-492_450`, 
CONSTRAINT `biomarker_range_user_id_ad579e08_fk` FOREIGN KEY (`user_id`) 
REFERENCES `auth_user` (`id`))')

Here is the model:

class Range(models.Model):
    user = models.ForeignKey(User, blank=True, null=True, 
related_name='ranges')

>From my understanding this is happening because you can't change the length 
of a field used as a foreign key in MySQL 
(see 
https://stackoverflow.com/questions/36386231/how-to-change-the-size-of-a-column-with-foreign-key-constraint)

That post suggests the foreign keys need to be deletes and added back in. 
I'm not sure I like the idea of deleting all my foreign keys against 
user_id (there are quite a few tables with this) and I'm also not sure 
where I would do this, given that the migration file is not mine, but 
belongs to Django's auth app.

Now surely I'm not the only person using MySQL who's come across this?

Any ideas?

Thanks,

Andrew.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c849748c-d14c-4e2c-a7d8-3202141e02e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to