mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-25 08:46:10 -06:00
IPAddressFunction: add migration, fix imports and constraints
This commit is contained in:
parent
63b946b339
commit
557c7d5f2e
44
netbox/ipam/migrations/0067_ipaddressfunction_and_more.py
Normal file
44
netbox/ipam/migrations/0067_ipaddressfunction_and_more.py
Normal file
@ -0,0 +1,44 @@
|
||||
# Generated by Django 4.1.9 on 2023-07-06 20:08
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import taggit.managers
|
||||
import utilities.json
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('extras', '0092_delete_jobresult'),
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
('ipam', '0066_iprange_mark_utilized'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='IPAddressFunction',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
|
||||
('created', models.DateTimeField(auto_now_add=True, null=True)),
|
||||
('last_updated', models.DateTimeField(auto_now=True, null=True)),
|
||||
('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)),
|
||||
('assigned_object_id', models.PositiveBigIntegerField()),
|
||||
('function', models.CharField(max_length=50)),
|
||||
('assigned_ip', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='ipam.ipaddress')),
|
||||
('assigned_object_type', models.ForeignKey(limit_choices_to=models.Q(models.Q(models.Q(('app_label', 'dcim'), ('model', 'device')), models.Q(('app_label', 'dcim'), ('model', 'virtualdevicecontext')), models.Q(('app_label', 'virtualization'), ('model', 'VirtualMachine')), _connector='OR')), on_delete=django.db.models.deletion.CASCADE, related_name='+', to='contenttypes.contenttype')),
|
||||
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'IP Address Function',
|
||||
'ordering': ('function',),
|
||||
},
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='ipaddressfunction',
|
||||
constraint=models.UniqueConstraint(fields=('assigned_object_type', 'assigned_object_id', 'function'), name='ipam_ipfunction_assigned_object'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='ipaddressfunction',
|
||||
constraint=models.UniqueConstraint(fields=('assigned_ip',), name='ipam_ipfunction_ip_single_use'),
|
||||
),
|
||||
]
|
@ -20,7 +20,7 @@ from netbox.models import OrganizationalModel, PrimaryModel, NetBoxModel
|
||||
__all__ = (
|
||||
'Aggregate',
|
||||
'IPAddress',
|
||||
'IPAddressFunction'
|
||||
'IPAddressFunction',
|
||||
'IPRange',
|
||||
'Prefix',
|
||||
'RIR',
|
||||
@ -701,7 +701,7 @@ class IPAddressFunction(NetBoxModel):
|
||||
name='ipam_ipfunction_assigned_object'
|
||||
),
|
||||
models.UniqueConstraint(
|
||||
fields=('assigned_ip'),
|
||||
fields=('assigned_ip',),
|
||||
name='ipam_ipfunction_ip_single_use'
|
||||
),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user