netbox/netbox/virtualization/migrations/0041_charfield_null_choices.py
Jeremy Stretch 343a4af591
Closes #18022: Extend linter (ruff) to enforce line length limit (120 chars) (#18067)
* Enable E501 rule
* Configure ruff formatter
* Reformat migration files to fix line length violations
* Fix various E501 errors
* Move table template code to template_code.py & ignore E501 errors
* Reformat raw SQL
2024-11-21 15:58:11 -05:00

26 lines
689 B
Python

from django.db import migrations, models
def set_null_values(apps, schema_editor):
"""
Replace empty strings with null values.
"""
VMInterface = apps.get_model('virtualization', 'VMInterface')
VMInterface.objects.filter(mode='').update(mode=None)
class Migration(migrations.Migration):
dependencies = [
('virtualization', '0040_convert_disk_size'),
]
operations = [
migrations.AlterField(
model_name='vminterface',
name='mode',
field=models.CharField(blank=True, max_length=50, null=True),
),
migrations.RunPython(code=set_null_values, reverse_code=migrations.RunPython.noop),
]