mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
Implement bypass for migration safeguard
This commit is contained in:
parent
8b92bc6c4a
commit
66464fd807
@ -5,6 +5,12 @@
|
||||
!!! warning "Python 3.8 or Later Required"
|
||||
NetBox v3.2 requires Python 3.8 or later.
|
||||
|
||||
!!! warning "Deletion of Legacy Data"
|
||||
This release includes a database migration that will remove the `asn`, `contact_name`, `contact_phone`, and `contact_email` fields from the site model. (These fields have been superseded by the ASN and contact models introduced in NetBox v3.1.) To protect against the accidental destruction of data, the upgrade process **will fail** if any sites still have data in any of these fields. To bypass this safeguard, set the `NETBOX_DELETE_LEGACY_DATA` environment variable when running the upgrade script, which will permit the destruction of legacy data.
|
||||
|
||||
!!! tip "Migration Scripts"
|
||||
A set of [migration scripts](https://github.com/netbox-community/migration-scripts) is available to assist with the migration of legacy site data.
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
* Automatic redirection of legacy slug-based URL paths has been removed. URL-based slugs were changed to use numeric IDs in v2.11.0.
|
||||
|
@ -1,3 +1,5 @@
|
||||
import os
|
||||
|
||||
from django.db import migrations
|
||||
from django.db.utils import DataError
|
||||
|
||||
@ -8,18 +10,22 @@ def check_legacy_data(apps, schema_editor):
|
||||
"""
|
||||
Site = apps.get_model('dcim', 'Site')
|
||||
|
||||
if site_count := Site.objects.exclude(asn__isnull=True).count():
|
||||
site_count = Site.objects.exclude(asn__isnull=True).count()
|
||||
if site_count and 'NETBOX_DELETE_LEGACY_DATA' not in os.environ:
|
||||
raise DataError(
|
||||
f"Unable to proceed with deleting asn field from Site model: Found {site_count} sites with "
|
||||
f"legacy ASN data. Please ensure all legacy site ASN data has been migrated to ASN objects "
|
||||
f"before proceeding."
|
||||
f"before proceeding. Or, set the NETBOX_DELETE_LEGACY_DATA environment variable to bypass "
|
||||
f"this safeguard and delete all legacy site ASN data."
|
||||
)
|
||||
|
||||
if site_count := Site.objects.exclude(contact_name='', contact_phone='', contact_email='').count():
|
||||
site_count = Site.objects.exclude(contact_name='', contact_phone='', contact_email='').count()
|
||||
if site_count and 'NETBOX_DELETE_LEGACY_DATA' not in os.environ:
|
||||
raise DataError(
|
||||
f"Unable to proceed with deleting contact fields from Site model: Found {site_count} sites "
|
||||
f"with legacy contact data. Please ensure all legacy site contact data has been migrated to "
|
||||
f"contact objects before proceeding."
|
||||
f"contact objects before proceeding. Or, set the NETBOX_DELETE_LEGACY_DATA environment "
|
||||
f"variable to bypass this safeguard and delete all legacy site contact data."
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user