From 68ecddccdb148176fb25347a1af6abd78fe0513b Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 16 Jul 2020 11:56:35 -0400 Subject: [PATCH] Convert NullBooleanField to BooleanField(null=True) --- .../0019_nullbooleanfield_to_booleanfield.py | 18 ++++++++ netbox/circuits/models.py | 5 ++- .../0113_nullbooleanfield_to_booleanfield.py | 43 +++++++++++++++++++ netbox/dcim/models/__init__.py | 5 ++- netbox/dcim/models/device_components.py | 25 ++++++----- 5 files changed, 82 insertions(+), 14 deletions(-) create mode 100644 netbox/circuits/migrations/0019_nullbooleanfield_to_booleanfield.py create mode 100644 netbox/dcim/migrations/0113_nullbooleanfield_to_booleanfield.py diff --git a/netbox/circuits/migrations/0019_nullbooleanfield_to_booleanfield.py b/netbox/circuits/migrations/0019_nullbooleanfield_to_booleanfield.py new file mode 100644 index 000000000..c8e844284 --- /dev/null +++ b/netbox/circuits/migrations/0019_nullbooleanfield_to_booleanfield.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1b1 on 2020-07-16 15:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('circuits', '0018_standardize_description'), + ] + + operations = [ + migrations.AlterField( + model_name='circuittermination', + name='connection_status', + field=models.BooleanField(blank=True, null=True), + ), + ] diff --git a/netbox/circuits/models.py b/netbox/circuits/models.py index 63491ca20..9ec90d110 100644 --- a/netbox/circuits/models.py +++ b/netbox/circuits/models.py @@ -275,9 +275,10 @@ class CircuitTermination(CableTermination): blank=True, null=True ) - connection_status = models.NullBooleanField( + connection_status = models.BooleanField( choices=CONNECTION_STATUS_CHOICES, - blank=True + blank=True, + null=True ) port_speed = models.PositiveIntegerField( verbose_name='Port speed (Kbps)' diff --git a/netbox/dcim/migrations/0113_nullbooleanfield_to_booleanfield.py b/netbox/dcim/migrations/0113_nullbooleanfield_to_booleanfield.py new file mode 100644 index 000000000..b96e2dcd4 --- /dev/null +++ b/netbox/dcim/migrations/0113_nullbooleanfield_to_booleanfield.py @@ -0,0 +1,43 @@ +# Generated by Django 3.1b1 on 2020-07-16 15:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dcim', '0112_standardize_components'), + ] + + operations = [ + migrations.AlterField( + model_name='consoleport', + name='connection_status', + field=models.BooleanField(blank=True, null=True), + ), + migrations.AlterField( + model_name='consoleserverport', + name='connection_status', + field=models.BooleanField(blank=True, null=True), + ), + migrations.AlterField( + model_name='interface', + name='connection_status', + field=models.BooleanField(blank=True, null=True), + ), + migrations.AlterField( + model_name='powerfeed', + name='connection_status', + field=models.BooleanField(blank=True, null=True), + ), + migrations.AlterField( + model_name='poweroutlet', + name='connection_status', + field=models.BooleanField(blank=True, null=True), + ), + migrations.AlterField( + model_name='powerport', + name='connection_status', + field=models.BooleanField(blank=True, null=True), + ), + ] diff --git a/netbox/dcim/models/__init__.py b/netbox/dcim/models/__init__.py index 9b1019990..9f4b23603 100644 --- a/netbox/dcim/models/__init__.py +++ b/netbox/dcim/models/__init__.py @@ -1905,9 +1905,10 @@ class PowerFeed(ChangeLoggedModel, CableTermination, CustomFieldModel): blank=True, null=True ) - connection_status = models.NullBooleanField( + connection_status = models.BooleanField( choices=CONNECTION_STATUS_CHOICES, - blank=True + blank=True, + null=True ) name = models.CharField( max_length=50 diff --git a/netbox/dcim/models/device_components.py b/netbox/dcim/models/device_components.py index 1ebb0c4d5..6764f8bcf 100644 --- a/netbox/dcim/models/device_components.py +++ b/netbox/dcim/models/device_components.py @@ -264,9 +264,10 @@ class ConsolePort(CableTermination, ComponentModel): blank=True, null=True ) - connection_status = models.NullBooleanField( + connection_status = models.BooleanField( choices=CONNECTION_STATUS_CHOICES, - blank=True + blank=True, + null=True ) tags = TaggableManager(through=TaggedItem) @@ -304,9 +305,10 @@ class ConsoleServerPort(CableTermination, ComponentModel): blank=True, help_text='Physical port type' ) - connection_status = models.NullBooleanField( + connection_status = models.BooleanField( choices=CONNECTION_STATUS_CHOICES, - blank=True + blank=True, + null=True ) tags = TaggableManager(through=TaggedItem) @@ -370,9 +372,10 @@ class PowerPort(CableTermination, ComponentModel): blank=True, null=True ) - connection_status = models.NullBooleanField( + connection_status = models.BooleanField( choices=CONNECTION_STATUS_CHOICES, - blank=True + blank=True, + null=True ) tags = TaggableManager(through=TaggedItem) @@ -505,9 +508,10 @@ class PowerOutlet(CableTermination, ComponentModel): blank=True, help_text="Phase (for three-phase feeds)" ) - connection_status = models.NullBooleanField( + connection_status = models.BooleanField( choices=CONNECTION_STATUS_CHOICES, - blank=True + blank=True, + null=True ) tags = TaggableManager(through=TaggedItem) @@ -598,9 +602,10 @@ class Interface(CableTermination, ComponentModel, BaseInterface): blank=True, null=True ) - connection_status = models.NullBooleanField( + connection_status = models.BooleanField( choices=CONNECTION_STATUS_CHOICES, - blank=True + blank=True, + null=True ) lag = models.ForeignKey( to='self',