mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-17 01:02:18 -06:00
Closes #17761: Store empty CharField choices as null
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
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
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user