[PATCH v4 2/3] models: Split Patch into two models

Finucane, Stephen stephen.finucane at intel.com
Sat Apr 2 01:54:12 AEDT 2016


On 25 Mar 17:29, Stephen Finucane wrote:
> There are a lot of similarities between cover letters and patches: so
> many, in fact, that it would be helpful to occasionally treat them as
> the same thing. Achieve this by extracting out the fields that would be
> shared between a Patch and a hypothetical cover letter into a "sub
> model". This allows us to do cool stuff like assigning comments to both
> patches and cover letters or listing both patches and cover letters on
> the main screen in a natural way.
> 
> The migrations for this are really the only complicated part. There are
> three, broken up into schema and data migrations per Django customs,
> and they works as follows:
> 
> * Rename the 'Patch' model to 'Submission', then create a subclass
>   called 'Patch' that includes duplicates of the patch-specific fields
>   of Submission (with changed names to prevent conflicts). Rename
>   non-patch specific references to the renamed 'Submission' model
>   as necessary.
> * Duplicate the contents of the patch-specific fields from 'Submission'
>   to 'Patch'
> * Remove the patch-specific fields from 'Submission', renaming the
>   'Patch' model to take their place. Update the patch-specific
>   references to point the new 'Patch' model, rather than 'Submission'.
> 
> This comes at the cost of an additional JOIN per item on the main
> screen, but this seems a small price to pay for the additional
> functionality gained. To minimise this, however, caching will be added.
> 
> Signed-off-by: Stephen Finucane <stephen.finucane at intel.com>
> Signed-off-by: Andy Doan <andy.doan at linaro.org>

Merged.


More information about the Patchwork mailing list