--- /dev/null
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.10 on 2018-03-08 01:51
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+ # per migration 16, but note this seems to be going away
+ # in new PostgreSQLs (https://stackoverflow.com/questions/12838111/south-cannot-alter-table-because-it-has-pending-trigger-events#comment44629663_12838113)
+ atomic = False
+
+ dependencies = [
+ ('patchwork', '0023_timezone_unify'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='patch',
+ name='patch_project',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='patchwork.Project'),
+ preserve_default=False,
+ ),
+
+ # as with 10, this will break if you use non-default table names
+ migrations.RunSQL('''UPDATE patchwork_patch SET patch_project_id =
+ (SELECT project_id FROM patchwork_submission
+ WHERE patchwork_submission.id =
+ patchwork_patch.submission_ptr_id);'''
+ ),
+
+ migrations.AlterField(
+ model_name='patch',
+ name='patch_project',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='patchwork.Project'),
+ ),
+
+ ]
archived = models.BooleanField(default=False)
hash = HashField(null=True, blank=True)
+ # duplicate project from submission in subclass so we can count the
+ # patches in a project without needing to do a JOIN.
+ patch_project = models.ForeignKey(Project, on_delete=models.CASCADE)
+
objects = PatchManager()
@staticmethod
context['filters'].set_status(filterclass, setting)
if patches is None:
- patches = Patch.objects.filter(project=project)
+ patches = Patch.objects.filter(patch_project=project)
# annotate with tag counts
patches = patches.with_tag_counts(project)