Passed
Push — master ( eaf1ad...4d7f40 )
by Alexander
02:18
created

tcms.testcases.migrations.0014_update_issutracker_types   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 19
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A forwards() 0 7 3
A backwards() 0 7 3
1
from django.db import migrations
2
3
4
def forwards(apps, schema_editor):
5
    BugSystem = apps.get_model('testcases', 'BugSystem')
6
7
    for record in BugSystem.objects.all():
8
        if record.tracker_type:
9
            record.tracker_type = "tcms.issuetracker.types.%s" % record.tracker_type
10
            record.save()
11
12
13
def backwards(apps, schema_editor):
14
    BugSystem = apps.get_model('testcases', 'BugSystem')
15
16
    for record in BugSystem.objects.all():
17
        if record.tracker_type.startswith('tcms.issuetracker.types.'):
18
            record.tracker_type = record.tracker_type.replace('tcms.issuetracker.types.', '')
19
            record.save()
20
21
22
class Migration(migrations.Migration):
23
24
    dependencies = [
25
        ('testcases', '0013_remove_autofield'),
26
    ]
27
28
    operations = [
29
        migrations.RunPython(forwards, backwards),
30
    ]
31