mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-16 12:38:17 -06:00
models: move from unique_together to constraints (fixes #3146)
This commit is contained in:
parent
068a0e2257
commit
ab0ea06018
29
netbox/circuits/migrations/0015_auto_20190526_1525.py
Normal file
29
netbox/circuits/migrations/0015_auto_20190526_1525.py
Normal file
@ -0,0 +1,29 @@
|
||||
# Generated by Django 2.2.1 on 2019-05-26 15:25
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('circuits', '0014_circuittermination_description'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterUniqueTogether(
|
||||
name='circuit',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='circuittermination',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='circuit',
|
||||
constraint=models.UniqueConstraint(fields=('provider', 'cid'), name='unique_provider_and_cid'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='circuittermination',
|
||||
constraint=models.UniqueConstraint(fields=('circuit', 'term_side'), name='unique_circuit_and_termside'),
|
||||
),
|
||||
]
|
@ -173,7 +173,11 @@ class Circuit(ChangeLoggedModel, CustomFieldModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['provider', 'cid']
|
||||
unique_together = ['provider', 'cid']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['provider', 'cid'], name='unique_provider_and_cid'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.cid
|
||||
@ -265,7 +269,12 @@ class CircuitTermination(CableTermination):
|
||||
|
||||
class Meta:
|
||||
ordering = ['circuit', 'term_side']
|
||||
unique_together = ['circuit', 'term_side']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['circuit', 'term_side'],
|
||||
name='unique_circuit_and_termside'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return 'Side {}'.format(self.get_term_side_display())
|
||||
|
228
netbox/dcim/migrations/0070_auto_20190526_1525.py
Normal file
228
netbox/dcim/migrations/0070_auto_20190526_1525.py
Normal file
@ -0,0 +1,228 @@
|
||||
# Generated by Django 2.2.1 on 2019-05-26 15:25
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dcim', '0069_deprecate_nullablecharfield'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='cable',
|
||||
name='termination_a_type',
|
||||
field=models.ForeignKey(limit_choices_to={'model__in': ['consoleport', 'consoleserverport', 'interface', 'poweroutlet', 'powerport', 'frontport', 'rearport', 'circuittermination']}, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='cable',
|
||||
name='termination_b_type',
|
||||
field=models.ForeignKey(limit_choices_to={'model__in': ['consoleport', 'consoleserverport', 'interface', 'poweroutlet', 'powerport', 'frontport', 'rearport', 'circuittermination']}, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType'),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='cable',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='consoleport',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='consoleporttemplate',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='consoleserverport',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='consoleserverporttemplate',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='device',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='devicebay',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='devicebaytemplate',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='devicetype',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='frontport',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='frontporttemplate',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='interface',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='interfacetemplate',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='inventoryitem',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='poweroutlet',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='poweroutlettemplate',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='powerport',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='powerporttemplate',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='rack',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='rackgroup',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='rearport',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='rearporttemplate',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='cable',
|
||||
constraint=models.UniqueConstraint(fields=('termination_a_type', 'termination_a_id'), name='unique_terminations_a_to_b_on_cable'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='cable',
|
||||
constraint=models.UniqueConstraint(fields=('termination_b_type', 'termination_b_id'), name='unique_terminations_b_to_a_on_cable'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='consoleport',
|
||||
constraint=models.UniqueConstraint(fields=('device', 'name'), name='unique_device_and_name_on_consoleport'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='consoleporttemplate',
|
||||
constraint=models.UniqueConstraint(fields=('device_type', 'name'), name='unique_devicetype_and_name_on_consoleporttemplate'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='consoleserverport',
|
||||
constraint=models.UniqueConstraint(fields=('device', 'name'), name='unique_device_and_name_on_consoleserverport'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='consoleserverporttemplate',
|
||||
constraint=models.UniqueConstraint(fields=('device_type', 'name'), name='unique_devicetype_and_name_on_consoleserverporttemplate'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='device',
|
||||
constraint=models.UniqueConstraint(fields=('rack', 'position', 'face'), name='unique_rack_and_position_and_face_on_device'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='device',
|
||||
constraint=models.UniqueConstraint(fields=('virtual_chassis', 'vc_position'), name='unique_virtualchassis_and_vcpos_on_device'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='devicebay',
|
||||
constraint=models.UniqueConstraint(fields=('device', 'name'), name='unique_device_and_name_on_devicebay'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='devicebaytemplate',
|
||||
constraint=models.UniqueConstraint(fields=('device_type', 'name'), name='unique_devicetype_and_name_on_devicebaytemplate'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='devicetype',
|
||||
constraint=models.UniqueConstraint(fields=('manufacturer', 'model'), name='unique_manufacturer_and_model_on_devicetype'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='devicetype',
|
||||
constraint=models.UniqueConstraint(fields=('manufacturer', 'slug'), name='unique_manufacturer_and_slug_on_devicetype'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='frontport',
|
||||
constraint=models.UniqueConstraint(fields=('device', 'name'), name='unique_device_and_name_on_frontport'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='frontport',
|
||||
constraint=models.UniqueConstraint(fields=('rear_port', 'rear_port_position'), name='unique_rearport_and_rearportpos_on_frontport'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='frontporttemplate',
|
||||
constraint=models.UniqueConstraint(fields=('device_type', 'name'), name='unique_devicetype_and_name_on_frontporttemplate'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='frontporttemplate',
|
||||
constraint=models.UniqueConstraint(fields=('rear_port', 'rear_port_position'), name='unique_rearport_and_rearportpos_on_frontporttemplate'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='interface',
|
||||
constraint=models.UniqueConstraint(fields=('device', 'name'), name='unique_device_and_name_on_interface'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='interfacetemplate',
|
||||
constraint=models.UniqueConstraint(fields=('device_type', 'name'), name='unique_devicetype_and_name_on_interfacetemplate'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='inventoryitem',
|
||||
constraint=models.UniqueConstraint(fields=('device', 'parent', 'name'), name='unique_device_and_parent_and_name_on_inventoryitem'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='poweroutlet',
|
||||
constraint=models.UniqueConstraint(fields=('device', 'name'), name='unique_device_and_name_on_poweroutlet'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='poweroutlettemplate',
|
||||
constraint=models.UniqueConstraint(fields=('device_type', 'name'), name='unique_devicetype_and_name_on_poweroutlettemplate'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='powerport',
|
||||
constraint=models.UniqueConstraint(fields=('device', 'name'), name='unique_device_and_name_on_powerport'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='powerporttemplate',
|
||||
constraint=models.UniqueConstraint(fields=('device_type', 'name'), name='unique_devicetype_and_name_on_powerporttemplate'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='rack',
|
||||
constraint=models.UniqueConstraint(fields=('group', 'name'), name='unique_group_and_name_on_rack'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='rack',
|
||||
constraint=models.UniqueConstraint(fields=('group', 'facility_id'), name='unique_group_and_facility_on_rack'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='rackgroup',
|
||||
constraint=models.UniqueConstraint(fields=('site', 'name'), name='unique_site_and_name_on_rackgroup'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='rackgroup',
|
||||
constraint=models.UniqueConstraint(fields=('site', 'slug'), name='unique_site_and_slug_on_rackgroup'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='rearport',
|
||||
constraint=models.UniqueConstraint(fields=('device', 'name'), name='unique_device_and_name_on_rearport'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='rearporttemplate',
|
||||
constraint=models.UniqueConstraint(fields=('device_type', 'name'), name='unique_devicetype_and_name_on_rearporttemplate'),
|
||||
),
|
||||
]
|
@ -388,9 +388,15 @@ class RackGroup(ChangeLoggedModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['site', 'name']
|
||||
unique_together = [
|
||||
['site', 'name'],
|
||||
['site', 'slug'],
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['site', 'name'],
|
||||
name='unique_site_and_name_on_rackgroup'
|
||||
),
|
||||
models.UniqueConstraint(
|
||||
fields=['site', 'slug'],
|
||||
name='unique_site_and_slug_on_rackgroup'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
@ -553,9 +559,15 @@ class Rack(ChangeLoggedModel, CustomFieldModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['site', 'group', 'name']
|
||||
unique_together = [
|
||||
['group', 'name'],
|
||||
['group', 'facility_id'],
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['group', 'name'],
|
||||
name='unique_group_and_name_on_rack'
|
||||
),
|
||||
models.UniqueConstraint(
|
||||
fields=['group', 'facility_id'],
|
||||
name='unique_group_and_facility_on_rack'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
@ -919,9 +931,16 @@ class DeviceType(ChangeLoggedModel, CustomFieldModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['manufacturer', 'model']
|
||||
unique_together = [
|
||||
['manufacturer', 'model'],
|
||||
['manufacturer', 'slug'],
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['manufacturer', 'model'],
|
||||
name='unique_manufacturer_and_model_on_devicetype'
|
||||
),
|
||||
models.UniqueConstraint(
|
||||
fields=['manufacturer', 'slug'],
|
||||
name='unique_manufacturer_and_slug_on_devicetype'
|
||||
)
|
||||
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
@ -1005,7 +1024,12 @@ class ConsolePortTemplate(ComponentTemplateModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['device_type', 'name']
|
||||
unique_together = ['device_type', 'name']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device_type', 'name'],
|
||||
name='unique_devicetype_and_name_on_consoleporttemplate'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@ -1028,7 +1052,12 @@ class ConsoleServerPortTemplate(ComponentTemplateModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['device_type', 'name']
|
||||
unique_together = ['device_type', 'name']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device_type', 'name'],
|
||||
name='unique_devicetype_and_name_on_consoleserverporttemplate'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@ -1063,7 +1092,12 @@ class PowerPortTemplate(ComponentTemplateModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['device_type', 'name']
|
||||
unique_together = ['device_type', 'name']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device_type', 'name'],
|
||||
name='unique_devicetype_and_name_on_powerporttemplate'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@ -1099,7 +1133,12 @@ class PowerOutletTemplate(ComponentTemplateModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['device_type', 'name']
|
||||
unique_together = ['device_type', 'name']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device_type', 'name'],
|
||||
name='unique_devicetype_and_name_on_poweroutlettemplate'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@ -1138,7 +1177,12 @@ class InterfaceTemplate(ComponentTemplateModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['device_type', 'name']
|
||||
unique_together = ['device_type', 'name']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device_type', 'name'],
|
||||
name='unique_devicetype_and_name_on_interfacetemplate'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@ -1189,9 +1233,15 @@ class FrontPortTemplate(ComponentTemplateModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['device_type', 'name']
|
||||
unique_together = [
|
||||
['device_type', 'name'],
|
||||
['rear_port', 'rear_port_position'],
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device_type', 'name'],
|
||||
name='unique_devicetype_and_name_on_frontporttemplate'
|
||||
),
|
||||
models.UniqueConstraint(
|
||||
fields=['rear_port', 'rear_port_position'],
|
||||
name='unique_rearport_and_rearportpos_on_frontporttemplate'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
@ -1238,7 +1288,12 @@ class RearPortTemplate(ComponentTemplateModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['device_type', 'name']
|
||||
unique_together = ['device_type', 'name']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device_type', 'name'],
|
||||
name='unique_devicetype_and_name_on_rearporttemplate'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@ -1261,7 +1316,12 @@ class DeviceBayTemplate(ComponentTemplateModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['device_type', 'name']
|
||||
unique_together = ['device_type', 'name']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device_type', 'name'],
|
||||
name='unique_devicetype_and_name_on_devicebaytemplate'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@ -1510,9 +1570,15 @@ class Device(ChangeLoggedModel, ConfigContextModel, CustomFieldModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['name']
|
||||
unique_together = [
|
||||
['rack', 'position', 'face'],
|
||||
['virtual_chassis', 'vc_position'],
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['rack', 'position', 'face'],
|
||||
name='unique_rack_and_position_and_face_on_device'
|
||||
),
|
||||
models.UniqueConstraint(
|
||||
fields=['virtual_chassis', 'vc_position'],
|
||||
name='unique_virtualchassis_and_vcpos_on_device'
|
||||
),
|
||||
]
|
||||
permissions = (
|
||||
('napalm_read', 'Read-only access to devices via NAPALM'),
|
||||
@ -1810,7 +1876,12 @@ class ConsolePort(CableTermination, ComponentModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['device', 'name']
|
||||
unique_together = ['device', 'name']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device', 'name'],
|
||||
name='unique_device_and_name_on_consoleport'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@ -1853,7 +1924,12 @@ class ConsoleServerPort(CableTermination, ComponentModel):
|
||||
csv_headers = ['device', 'name', 'description']
|
||||
|
||||
class Meta:
|
||||
unique_together = ['device', 'name']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device', 'name'],
|
||||
name='unique_device_and_name_on_consoleserverport'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@ -1923,7 +1999,12 @@ class PowerPort(CableTermination, ComponentModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['device', 'name']
|
||||
unique_together = ['device', 'name']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device', 'name'],
|
||||
name='unique_device_and_name_on_powerport'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@ -2046,7 +2127,12 @@ class PowerOutlet(CableTermination, ComponentModel):
|
||||
csv_headers = ['device', 'name', 'power_port', 'feed_leg', 'description']
|
||||
|
||||
class Meta:
|
||||
unique_together = ['device', 'name']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device', 'name'],
|
||||
name='unique_device_and_name_on_poweroutlet'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@ -2177,7 +2263,12 @@ class Interface(CableTermination, ComponentModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['device', 'name']
|
||||
unique_together = ['device', 'name']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device', 'name'],
|
||||
name='unique_device_and_name_on_interface'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@ -2387,9 +2478,15 @@ class FrontPort(CableTermination, ComponentModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['device', 'name']
|
||||
unique_together = [
|
||||
['device', 'name'],
|
||||
['rear_port', 'rear_port_position'],
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device', 'name'],
|
||||
name='unique_device_and_name_on_frontport'
|
||||
),
|
||||
models.UniqueConstraint(
|
||||
fields=['rear_port', 'rear_port_position'],
|
||||
name='unique_rearport_and_rearportpos_on_frontport'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
@ -2449,7 +2546,12 @@ class RearPort(CableTermination, ComponentModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['device', 'name']
|
||||
unique_together = ['device', 'name']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device', 'name'],
|
||||
name='unique_device_and_name_on_rearport'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@ -2496,7 +2598,12 @@ class DeviceBay(ComponentModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['device', 'name']
|
||||
unique_together = ['device', 'name']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device', 'name'],
|
||||
name='unique_device_and_name_on_devicebay',
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return '{} - {}'.format(self.device.name, self.name)
|
||||
@ -2588,7 +2695,12 @@ class InventoryItem(ComponentModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['device__id', 'parent__id', 'name']
|
||||
unique_together = ['device', 'parent', 'name']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device', 'parent', 'name'],
|
||||
name='unique_device_and_parent_and_name_on_inventoryitem'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@ -2727,10 +2839,16 @@ class Cable(ChangeLoggedModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['pk']
|
||||
unique_together = (
|
||||
('termination_a_type', 'termination_a_id'),
|
||||
('termination_b_type', 'termination_b_id'),
|
||||
)
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['termination_a_type', 'termination_a_id'],
|
||||
name='unique_terminations_a_to_b_on_cable'
|
||||
),
|
||||
models.UniqueConstraint(
|
||||
fields=['termination_b_type', 'termination_b_id'],
|
||||
name='unique_terminations_b_to_a_on_cable'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
if self.label:
|
||||
|
45
netbox/extras/migrations/0019_auto_20190526_1525.py
Normal file
45
netbox/extras/migrations/0019_auto_20190526_1525.py
Normal file
@ -0,0 +1,45 @@
|
||||
# Generated by Django 2.2.1 on 2019-05-26 15:25
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('extras', '0018_exporttemplate_add_jinja2'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterUniqueTogether(
|
||||
name='customfieldchoice',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='customfieldvalue',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='exporttemplate',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='webhook',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='customfieldchoice',
|
||||
constraint=models.UniqueConstraint(fields=('field', 'value'), name='unique_field_and_value_on_customfieldchoice'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='customfieldvalue',
|
||||
constraint=models.UniqueConstraint(fields=('field', 'obj_type', 'obj_id'), name='unique_custom_field_on_customfieldvalue'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='exporttemplate',
|
||||
constraint=models.UniqueConstraint(fields=('content_type', 'name'), name='unique_name_and_type_on_exporttemplate'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='webhook',
|
||||
constraint=models.UniqueConstraint(fields=('payload_url', 'type_create', 'type_update', 'type_delete'), name='unique_webhook_type_and_payload_on_webhook'),
|
||||
),
|
||||
]
|
@ -88,7 +88,14 @@ class Webhook(models.Model):
|
||||
)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('payload_url', 'type_create', 'type_update', 'type_delete',)
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=[
|
||||
'payload_url', 'type_create', 'type_update', 'type_delete'
|
||||
],
|
||||
name='unique_webhook_type_and_payload_on_webhook'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@ -259,7 +266,12 @@ class CustomFieldValue(models.Model):
|
||||
|
||||
class Meta:
|
||||
ordering = ['obj_type', 'obj_id']
|
||||
unique_together = ['field', 'obj_type', 'obj_id']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['field', 'obj_type', 'obj_id'],
|
||||
name='unique_custom_field_on_customfieldvalue'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return '{} {}'.format(self.obj, self.field)
|
||||
@ -297,7 +309,12 @@ class CustomFieldChoice(models.Model):
|
||||
|
||||
class Meta:
|
||||
ordering = ['field', 'weight', 'value']
|
||||
unique_together = ['field', 'value']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['field', 'value'],
|
||||
name='unique_field_and_value_on_customfieldchoice'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
@ -447,8 +464,11 @@ class ExportTemplate(models.Model):
|
||||
|
||||
class Meta:
|
||||
ordering = ['content_type', 'name']
|
||||
unique_together = [
|
||||
['content_type', 'name']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['content_type', 'name'],
|
||||
name='unique_name_and_type_on_exporttemplate'
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
|
37
netbox/ipam/migrations/0025_auto_20190526_1525.py
Normal file
37
netbox/ipam/migrations/0025_auto_20190526_1525.py
Normal file
@ -0,0 +1,37 @@
|
||||
# Generated by Django 2.2.1 on 2019-05-26 15:25
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('ipam', '0024_vrf_allow_null_rd'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterUniqueTogether(
|
||||
name='vlan',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='vlangroup',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='vlan',
|
||||
constraint=models.UniqueConstraint(fields=('group', 'vid'), name='unique_group_and_vid_on_vlan'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='vlan',
|
||||
constraint=models.UniqueConstraint(fields=('group', 'name'), name='unique_group_and_name_on_vlan'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='vlangroup',
|
||||
constraint=models.UniqueConstraint(fields=('site', 'name'), name='unique_site_and_name_on_vlangroup'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='vlangroup',
|
||||
constraint=models.UniqueConstraint(fields=('site', 'slug'), name='unique_site_and_slug_on_vlangroup'),
|
||||
),
|
||||
]
|
@ -740,9 +740,15 @@ class VLANGroup(ChangeLoggedModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['site', 'name']
|
||||
unique_together = [
|
||||
['site', 'name'],
|
||||
['site', 'slug'],
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['site', 'name'],
|
||||
name='unique_site_and_name_on_vlangroup'
|
||||
),
|
||||
models.UniqueConstraint(
|
||||
fields=['site', 'slug'],
|
||||
name='unique_site_and_slug_on_vlangroup'
|
||||
)
|
||||
]
|
||||
verbose_name = 'VLAN group'
|
||||
verbose_name_plural = 'VLAN groups'
|
||||
@ -836,9 +842,15 @@ class VLAN(ChangeLoggedModel, CustomFieldModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['site', 'group', 'vid']
|
||||
unique_together = [
|
||||
['group', 'vid'],
|
||||
['group', 'name'],
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['group', 'vid'],
|
||||
name='unique_group_and_vid_on_vlan'
|
||||
),
|
||||
models.UniqueConstraint(
|
||||
fields=['group', 'name'],
|
||||
name='unique_group_and_name_on_vlan'
|
||||
)
|
||||
]
|
||||
verbose_name = 'VLAN'
|
||||
verbose_name_plural = 'VLANs'
|
||||
|
21
netbox/secrets/migrations/0006_auto_20190526_1525.py
Normal file
21
netbox/secrets/migrations/0006_auto_20190526_1525.py
Normal file
@ -0,0 +1,21 @@
|
||||
# Generated by Django 2.2.1 on 2019-05-26 15:25
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('secrets', '0005_change_logging'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterUniqueTogether(
|
||||
name='secret',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='secret',
|
||||
constraint=models.UniqueConstraint(fields=('device', 'role', 'name'), name='unique_device_and_role_and_name'),
|
||||
),
|
||||
]
|
@ -352,7 +352,12 @@ class Secret(ChangeLoggedModel, CustomFieldModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ['device', 'role', 'name']
|
||||
unique_together = ['device', 'role', 'name']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['device', 'role', 'name'],
|
||||
name='unique_device_and_role_and_name'
|
||||
)
|
||||
]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.plaintext = kwargs.pop('plaintext', None)
|
||||
|
Loading…
Reference in New Issue
Block a user