#24264: foreign key constraint error migrating integer pk to CharField
--------------------------------------+---------------------------
               Reporter:  timgraham   |          Owner:  nobody
                   Type:  Bug         |         Status:  new
              Component:  Migrations  |        Version:  1.8alpha1
               Severity:  Normal      |       Keywords:
           Triage Stage:  Unreviewed  |      Has patch:  0
    Needs documentation:  0           |    Needs tests:  0
Patch needs improvement:  0           |  Easy pickings:  0
                  UI/UX:  0           |
--------------------------------------+---------------------------
 Discovered while trying to update djangoproject.com to 1.8a1. See
 https://github.com/django/djangoproject.com/pull/373 for steps to
 reproduce.
 {{{
 $ python manage.py test fundraising
 ...
 foreign key constraint
 "fundrais_donor_id_50d7dcbcff28bd90_fk_fundraising_djangohero_id" cannot
 be implemented
 DETAIL:  Key columns "donor_id" and "id" are of incompatible types:
 integer and character varying.
 }}}

 Bisected to bbbed99f6260a8b3e65cb990e49721b1ce4a441b

 Here's a test for `tests/schema/tests.py` which is at least a start (it
 fails on 1.7.x too, so it's probably not quite right):
 {{{
 def test_change_int_pk_to_char(self):
     with connection.schema_editor() as editor:
         editor.create_model(Author)
         editor.create_model(Book)
     new_field = CharField(max_length=15, primary_key=True)
     new_field.set_attributes_from_name("id")
     new_field.model = Author
     with connection.schema_editor() as editor:
         editor.alter_field(Author, Author._meta.get_field("id"),
 new_field)
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24264>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.17086cb0a2b9ca90ad8931ee46ba6915%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to