|
| 1 | +# Generated by Django 5.2.7 on 2026-01-26 06:44 |
| 2 | + |
| 3 | +import django.db.models.deletion |
| 4 | +import django.utils.timezone |
| 5 | +import model_utils.fields |
| 6 | +from django.db import migrations, models |
| 7 | + |
| 8 | +import common.fields |
| 9 | + |
| 10 | + |
| 11 | +def forwards(apps, schema_editor): |
| 12 | + WealthCharacteristic = apps.get_model("metadata", "WealthCharacteristic") |
| 13 | + WealthCharacteristic.objects.update(characteristic_group=None) |
| 14 | + |
| 15 | + |
| 16 | +class Migration(migrations.Migration): |
| 17 | + |
| 18 | + dependencies = [ |
| 19 | + ("metadata", "0013_wealthcharacteristic_characteristic_group"), |
| 20 | + ] |
| 21 | + |
| 22 | + operations = [ |
| 23 | + migrations.RunPython( |
| 24 | + code=forwards, |
| 25 | + reverse_code=migrations.RunPython.noop, |
| 26 | + ), |
| 27 | + migrations.CreateModel( |
| 28 | + name="CharacteristicGroup", |
| 29 | + fields=[ |
| 30 | + ( |
| 31 | + "created", |
| 32 | + model_utils.fields.AutoCreatedField( |
| 33 | + default=django.utils.timezone.now, editable=False, verbose_name="created" |
| 34 | + ), |
| 35 | + ), |
| 36 | + ( |
| 37 | + "modified", |
| 38 | + model_utils.fields.AutoLastModifiedField( |
| 39 | + default=django.utils.timezone.now, editable=False, verbose_name="modified" |
| 40 | + ), |
| 41 | + ), |
| 42 | + ( |
| 43 | + "code", |
| 44 | + common.fields.CodeField(max_length=60, primary_key=True, serialize=False, verbose_name="Code"), |
| 45 | + ), |
| 46 | + ( |
| 47 | + "ordering", |
| 48 | + models.PositiveSmallIntegerField( |
| 49 | + blank=True, |
| 50 | + help_text="The order to display the items in when sorting by this field, if not obvious.", |
| 51 | + null=True, |
| 52 | + verbose_name="Ordering", |
| 53 | + ), |
| 54 | + ), |
| 55 | + ( |
| 56 | + "aliases", |
| 57 | + models.JSONField( |
| 58 | + blank=True, |
| 59 | + help_text="A list of alternate names for the object.", |
| 60 | + null=True, |
| 61 | + verbose_name="aliases", |
| 62 | + ), |
| 63 | + ), |
| 64 | + ("name_en", common.fields.NameField(max_length=60, verbose_name="Name")), |
| 65 | + ("name_fr", common.fields.NameField(blank=True, max_length=60, verbose_name="Name")), |
| 66 | + ("name_es", common.fields.NameField(blank=True, max_length=60, verbose_name="Name")), |
| 67 | + ("name_pt", common.fields.NameField(blank=True, max_length=60, verbose_name="Name")), |
| 68 | + ("name_ar", common.fields.NameField(blank=True, max_length=60, verbose_name="Name")), |
| 69 | + ( |
| 70 | + "description_en", |
| 71 | + common.fields.DescriptionField( |
| 72 | + blank=True, |
| 73 | + help_text="Any extra information or detail that is relevant to the object.", |
| 74 | + max_length=2000, |
| 75 | + verbose_name="Description", |
| 76 | + ), |
| 77 | + ), |
| 78 | + ( |
| 79 | + "description_fr", |
| 80 | + common.fields.DescriptionField( |
| 81 | + blank=True, |
| 82 | + help_text="Any extra information or detail that is relevant to the object.", |
| 83 | + max_length=2000, |
| 84 | + verbose_name="Description", |
| 85 | + ), |
| 86 | + ), |
| 87 | + ( |
| 88 | + "description_es", |
| 89 | + common.fields.DescriptionField( |
| 90 | + blank=True, |
| 91 | + help_text="Any extra information or detail that is relevant to the object.", |
| 92 | + max_length=2000, |
| 93 | + verbose_name="Description", |
| 94 | + ), |
| 95 | + ), |
| 96 | + ( |
| 97 | + "description_pt", |
| 98 | + common.fields.DescriptionField( |
| 99 | + blank=True, |
| 100 | + help_text="Any extra information or detail that is relevant to the object.", |
| 101 | + max_length=2000, |
| 102 | + verbose_name="Description", |
| 103 | + ), |
| 104 | + ), |
| 105 | + ( |
| 106 | + "description_ar", |
| 107 | + common.fields.DescriptionField( |
| 108 | + blank=True, |
| 109 | + help_text="Any extra information or detail that is relevant to the object.", |
| 110 | + max_length=2000, |
| 111 | + verbose_name="Description", |
| 112 | + ), |
| 113 | + ), |
| 114 | + ], |
| 115 | + options={ |
| 116 | + "verbose_name": "Characteristic Group", |
| 117 | + "verbose_name_plural": "Characteristic Groups", |
| 118 | + }, |
| 119 | + ), |
| 120 | + migrations.AlterField( |
| 121 | + model_name="wealthcharacteristic", |
| 122 | + name="characteristic_group", |
| 123 | + field=models.ForeignKey( |
| 124 | + blank=True, |
| 125 | + db_column="characteristic_group", # Add this line |
| 126 | + help_text="Optional grouping for characteristics, such as 'Population', 'Income', 'Land', 'Livestock', 'Other assets'", |
| 127 | + null=True, |
| 128 | + on_delete=django.db.models.deletion.PROTECT, |
| 129 | + to="metadata.characteristicgroup", |
| 130 | + verbose_name="Characteristic Group", |
| 131 | + ), |
| 132 | + ), |
| 133 | + ] |
0 commit comments