• 
      

    Add on_delete to ForeignKey definitions.

    Review Request #11988 — Created Jan. 24, 2022 and submitted

    Information

    Review Board
    master

    Reviewers

    Django has made the on_delete argument to ForeignKey mandatory.
    Until now, this has defaulted to CASCADE, which makes it easy to
    unintentionally delete things that shouldn't be deleted. Making it a
    required argument forces developers to think about each model and how it
    should behave.

    This change explicitly sets on_delete for every relation we have. Most
    of these are CASCADE, but the diff data ones are SET_NULL because
    those are effectively a one-to-many relation, and we don't want to
    delete diff data that may be shared by other diffs.

    Ran unit tests.

    Summary ID
    Add on_delete to ForeignKey definitions.
    Django has made the `on_delete` argument to `ForeignKey` mandatory. Until now, this has defaulted to `CASCADE`, which makes it easy to unintentionally delete things that shouldn't be deleted. Making it a required argument forces developers to think about each model and how it should behave. This change explicitly sets `on_delete` for every relation we have. Most of these are `CASCADE`, but the diff data ones are `SET_NULL` because those are effectively a one-to-many relation, and we don't want to delete diff data that may be shared by other diffs. Testing Done: Ran unit tests.
    a6eb4c8323c57a65ff0f425ab8ac8ec907436ea4
    Description From Last Updated

    Easy to miss in this change, but the diff data are all SET_NULL. Can you update the description to call …

    chipx86chipx86

    E501 line too long (83 > 79 characters)

    reviewbotreviewbot
    Checks run (1 failed, 1 succeeded)
    flake8 failed.
    JSHint passed.

    flake8

    david
    chipx86
    1. 
        
    2. Show all issues

      Easy to miss in this change, but the diff data are all SET_NULL. Can you update the description to call this out and talk about it?

    3. 
        
    david
    chipx86
    1. Ship It!
    2. 
        
    david
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to django-3.2 (c3505d7)