diff --git a/netbox_dns/migrations/0019_update_ns_ttl.py b/netbox_dns/migrations/0019_update_ns_ttl.py new file mode 100644 index 0000000..2c3656a --- /dev/null +++ b/netbox_dns/migrations/0019_update_ns_ttl.py @@ -0,0 +1,20 @@ +from django.db import migrations + + +def update_ns_ttl(apps, schema_editor): + Zone = apps.get_model("netbox_dns", "Zone") + + for zone in Zone.objects.all(): + for nameserver in zone.nameservers.all(): + nameserver.ttl = None + + +class Migration(migrations.Migration): + + dependencies = [ + ("netbox_dns", "0018_zone_arpa_network"), + ] + + operations = [ + migrations.RunPython(update_ns_ttl), + ] diff --git a/netbox_dns/models.py b/netbox_dns/models.py index 59746ae..f511ead 100644 --- a/netbox_dns/models.py +++ b/netbox_dns/models.py @@ -273,7 +273,6 @@ def update_soa_record(self): def update_ns_records(self, nameservers): ns_name = "@" - ns_ttl = self.default_ttl delete_ns = self.record_set.filter( type=RecordTypeChoices.NS, managed=True @@ -286,7 +285,6 @@ def update_ns_records(self, nameservers): zone_id=self.pk, type=RecordTypeChoices.NS, name=ns_name, - ttl=ns_ttl, value=ns, managed=True, )