Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

# -*- coding: utf-8 -*- 

# Generated by Django 1.11 on 2018-09-12 18:00 

from __future__ import unicode_literals 

 

from django.db import migrations, models 

 

 

def migrate_bool_to_int(apps, _): 

 

Person = apps.get_model('members', 'Person') 

 

12 ↛ 13line 12 didn't jump to line 13, because the loop on line 12 never started for person in Person.objects.all(): 

person.address_unknown = 1 if person.address_unknown_old else 0 

person.save() 

 

 

def migrate_int_to_bool(apps, _): 

 

Person = apps.get_model('members', 'Person') 

 

for person in Person.objects.all(): 

person.address_unknown_old = person.address_unknown > 0 

person.save() 

 

 

class Migration(migrations.Migration): 

 

dependencies = [ 

('members', '0028_auto_20180629_1813'), 

] 

 

operations = [ 

migrations.RenameField( 

model_name='person', 

old_name='address_unknown', 

new_name='address_unknown_old', 

), 

migrations.AddField( 

model_name='person', 

name='address_unknown', 

field=models.PositiveIntegerField(default=0, help_text='Counter of returned snail mail. 2 or more will be considered as unreachable. Is automatically reset to 0 when modifying any partof the address'), 

), 

migrations.RunPython(code=migrate_bool_to_int, reverse_code=migrate_int_to_bool), 

migrations.RemoveField( 

model_name='person', 

name='address_unknown_old', 

), 

]