]> git.ipfire.org Git - thirdparty/patchwork.git/commit
models: Split 'CoverLetter' from 'Submission'
authorStephen Finucane <stephen@that.guru>
Sat, 29 Feb 2020 17:20:50 +0000 (17:20 +0000)
committerStephen Finucane <stephen@that.guru>
Sun, 26 Apr 2020 12:45:45 +0000 (13:45 +0100)
commit0686a736fbf6d869bd31bd135ba38080ac96de22
tree61ce6dd17c29820680f588fce62e88a07ffcf1b4
parent13ff6b2f1a82760dca432296455a3761b34739ed
models: Split 'CoverLetter' from 'Submission'

We want to get rid of the split between 'Patch' and 'Submission' because
of the cost of using JOINs basically everywhere we use 'Patch'. Before
we do that, we need to move the other users of 'Submission' to other
models and other models that rely on these users sharing the common
'Submission' base. For the former, there is only one user,
'CoverLetter', while for the latter there is only the 'Comment' model.
As a result, we must do the following:

- Create a new 'Cover' model
- Create a new 'CoverComment' model
- Move everything from 'CoverLetter' to 'Cover' and all entries
  associated with a 'CoverLetter' from 'Comment' to 'CoverComment'
- Delete the 'CoverLetter' model
- Rename the 'Comment' model to 'PatchComment'

This means our model "hierarchy" goes from:

  Submission
    Patch
    CoverLetter
    Comment

To:

  Submission
    Patch
    PatchComment
  Cover
    CoverComment

A future change will flatten the 'Submission' and 'Patch' model.

Note that this actually highlighted a bug in Django, which has since
been reported upstream [1]. As noted there, the issue stems from MySQL's
refusal to remove an index from a foreign key when DB constraints are
used and the workaround is to remove the foreign key constraint before
altering the indexes and then re-add the constraint after.

[1] https://code.djangoproject.com/ticket/31335

Signed-off-by: Stephen Finucane <stephen@that.guru>
22 files changed:
patchwork/admin.py
patchwork/api/comment.py
patchwork/api/cover.py
patchwork/api/embedded.py
patchwork/api/filters.py
patchwork/management/commands/parsearchive.py
patchwork/migrations/0042_add_cover_model.py [new file with mode: 0644]
patchwork/models.py
patchwork/parser.py
patchwork/signals.py
patchwork/tests/api/test_comment.py
patchwork/tests/test_detail.py
patchwork/tests/test_mboxviews.py
patchwork/tests/test_parser.py
patchwork/tests/test_series.py
patchwork/tests/test_tags.py
patchwork/tests/utils.py
patchwork/urls.py
patchwork/views/comment.py
patchwork/views/cover.py
patchwork/views/patch.py
patchwork/views/utils.py