blob: 4083847fd6b42b5544ed3987ff445ca9199d0d1b (
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
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('patchwork', '0031_add_patch_series_fields'),
]
operations = [
# Copy SeriesPatch.series, SeriesPatch.number to Patch.series_alt,
# Patch.number. Note that there is no uniqueness check here because no
# code actually allowed us to save multiple series
migrations.RunSQL(
"""UPDATE patchwork_patch SET series_alt_id =
(SELECT series_id from patchwork_seriespatch
WHERE patchwork_seriespatch.patch_id =
patchwork_patch.submission_ptr_id);
UPDATE patchwork_patch SET number =
(SELECT number from patchwork_seriespatch
WHERE patchwork_seriespatch.patch_id =
patchwork_patch.submission_ptr_id);
""",
"""INSERT INTO patchwork_seriespatch
(patch_id, series_id, number)
SELECT submission_ptr_id, series_alt_id, number
FROM patchwork_patch;
""",
),
]
|