Coverage for migrations / 0030_migrate_more_props.py: 0%

27 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-22 07:15 +0000

1# Generated by Django 4.2.27 on 2026-01-16 

2 

3import pgtrigger 

4from django.db import migrations 

5 

6 

7def forward(apps, schema_editor): 

8 FormKitSchemaNode = apps.get_model("formkit_ninja", "FormKitSchemaNode") 

9 

10 with pgtrigger.ignore("formkit_ninja.FormKitSchemaNode:protect_node_updates"): 

11 for node in FormKitSchemaNode.objects.filter(additional_props__isnull=False).iterator(): 

12 changed = False 

13 props = node.additional_props 

14 if not isinstance(props, dict): 

15 continue 

16 

17 if "readonly" in props: 

18 val = props.pop("readonly") 

19 # Ensure boolean 

20 if val is True or val == "true": 

21 node.readonly = True 

22 changed = True 

23 

24 if "sectionsSchema" in props: 

25 node.sections_schema = props.pop("sectionsSchema") 

26 changed = True 

27 

28 if "min" in props: 

29 node.min = str(props.pop("min")) 

30 changed = True 

31 

32 if changed: 

33 node.additional_props = props 

34 node.save() 

35 

36 

37class Migration(migrations.Migration): 

38 dependencies = [ 

39 ("formkit_ninja", "0029_remove_formkitschemanode_insert_insert_and_more"), 

40 ] 

41 

42 operations = [ 

43 migrations.RunPython(forward, migrations.RunPython.noop), 

44 ]