Changes between Initial Version and Version 4 of Ticket #24447


Ignore:
Timestamp:
Mar 4, 2015, 6:17:45 PM (10 years ago)
Author:
Jean-Louis Fuchs
Comment:

Removed redundant information and chose clearer title.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #24447

    • Property Patch needs improvement set
    • Property Triage Stage UnreviewedAccepted
    • Property Version master1.7
    • Property Cc Markus Holtermann added
    • Property Needs documentation set
    • Property Summary Migrations do not execute create_fk_sql() when adding a foreign key to a fieldMigrations do not add a FK constraint for an existing column
  • Ticket #24447 – Description

    initial v4  
    1 Migrations failed when introducing foreign keys on existing fields.
    2 
    31Pull request: https://github.com/django/django/pull/4235
    4 Branch with fix: https://github.com/ganwell/django/tree/master_missing_create_fk_sql
    5 Branch with unittest but no fix: https://github.com/ganwell/django/tree/master_missing_create_fk_sql_fail
    62
    73Consider following model:
     
    2723}}}
    2824
    29 The second migration won't create the foreign key. This does not fail with sqlite! Because these migrations are handled differently. It will fail with MySQL and probably Postgres too. I wrote a unittest and tested it with MySQL: master_missing_create_fk_sql_fail fails and master_missing_create_fk_sql is ok.
     25The second migration won't create the foreign key. This does not fail with sqlite! Because these migrations are handled differently. It will fail with MySQL and probably Postgres too.
    3026
    31 The code didn't detect this case - if old_field.rel doesn't exist alter_field() must always create the foreign key and ONLY if .rel exists it must check .db_constraint, too. Since no .rel also means there was no foreign key before.
    32 
    33 I will of course redo the pull request to get clean history. I also fixed this in 1.7.
     27The code didn't detect this case: if old_field.rel doesn't exist alter_field() must always create the foreign key and ONLY if .rel exists it must check .db_constraint, too. Since no .rel also means there was no foreign key before.
Back to Top