summaryrefslogtreecommitdiff
path: root/patchwork/migrations/0009_add_submission_model.py
blob: f3468e6fe4f40de1bd7c9e4d2e4a259c0bf7b6ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion

import patchwork.models


class Migration(migrations.Migration):

    dependencies = [
        ('patchwork', '0008_add_email_mixin'),
    ]

    operations = [
        # Rename the 'Patch' to 'Submission'
        migrations.RenameModel(old_name='Patch', new_name='Submission'),
        migrations.AlterModelOptions(
            name='submission', options={'ordering': ['date']},
        ),
        # Rename the non-Patch specific references to point to Submission
        migrations.RenameField(
            model_name='comment', old_name='patch', new_name='submission',
        ),
        migrations.AlterUniqueTogether(
            name='comment', unique_together=set([('msgid', 'submission')]),
        ),
        migrations.RenameField(
            model_name='userprofile',
            old_name='patches_per_page',
            new_name='items_per_page',
        ),
        migrations.AlterField(
            model_name='userprofile',
            name='items_per_page',
            field=models.PositiveIntegerField(
                default=100, help_text=b'Number of items to display per page'
            ),
        ),
        # Recreate the 'Patch' model as a subclass of 'Submission'. Each field
        # is given a unique name to prevent it conflicting with the same field
        # found in the 'Submission' "super model". We will fix this later.
        migrations.CreateModel(
            name='Patch',
            fields=[
                (
                    'submission_ptr',
                    models.OneToOneField(
                        parent_link=True,
                        auto_created=True,
                        primary_key=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        serialize=False,
                        to='patchwork.Submission',
                    ),
                ),
                ('diff2', models.TextField(null=True, blank=True)),
                (
                    'commit_ref2',
                    models.CharField(max_length=255, null=True, blank=True),
                ),
                (
                    'pull_url2',
                    models.CharField(max_length=255, null=True, blank=True),
                ),
                # we won't migrate the data of this, seeing as it's
                # automatically recreated every time we save a Patch
                (
                    'tags2',
                    models.ManyToManyField(
                        to='patchwork.Tag', through='patchwork.PatchTag'
                    ),
                ),
                (
                    'delegate2',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        blank=True,
                        to=settings.AUTH_USER_MODEL,
                        null=True,
                    ),
                ),
                (
                    'state2',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to='patchwork.State',
                    ),
                ),
                ('archived2', models.BooleanField(default=False)),
                (
                    'hash2',
                    patchwork.models.HashField(
                        max_length=40, null=True, blank=True
                    ),
                ),
            ],
            options={'verbose_name_plural': 'Patches'},
            bases=('patchwork.submission',),
        ),
    ]